Rust常用数据结构教程 序列

文章目录

  • 一、Vec
    • 1.Vec与堆栈
    • 2.什么时候需要Vec
    • 3.get()方法
    • 4.与枚举的结合
  • 二、VecDeque
    • 1.什么情况适合VecDeque
    • 2.VecDeque的方法
  • 三、LinkedList
    • 1.什么时候用LinkedList
  • 参考

一、Vec

可变数组(vector)数组存储在heap上,在运行时(runtime)可以增加或减少数组

长度

  • 有人把Vector翻译为矢量
  • 注意默认还是不可变

1.Vec与堆栈

Vec的buf是存储在heap上的,其他存储在栈上

pub struct Vec<T, #[unstable(feature = "allocator_api'", issue = "32838")] A:Alocator=Global>
{
buf: RawVec<T, A>,
len: usize, //长度
}pub(crate) struct RawVec<T, A: Allocator = Global> {
ptr: Unique<T>, // 指向
cap: usize, // capacity
alloc: A,
}

2.什么时候需要Vec

·首选Vec:当你不知道用什么的时候,试试Vec,性能强悍有保证
·当你想要一个长度实时变化的数据存储单元时
·当你希望自己的存储单元有序时
·当你希望内存中各个元素的存储地址是连续时

#[derive(Debug, Clone)]
struct Car {id: i32,name: String,
}fn main() {// 初始化方法let my_vec = vec![2, 3, 4];println!("{:#?}: {}", my_vec, my_vec.capacity());// /这里的语法表示创建一个长度为 3 的向量,并用 2 填充每个元素let my_vec = vec![2; 3];println!("{:#?}: {}", my_vec, my_vec.capacity());// 可以显示声明类型,也可以不显示声明类型let my_vec: Vec<i32> = Vec::new();println!("{:#?}: {}", my_vec, my_vec.capacity());let my_vec: Vec<i32> = Vec::with_capacity(5);println!("{:#?}: {}", my_vec, my_vec.capacity());// pushlet mut cars = Vec::new();for i in 1..11 {let car_type = if i % 2 == 0 { "car" } else { "bus" };cars.push(Car {id: i,name: format!("{}-{}", car_type, i),});}println!("{:?}", cars);//删除poplet car = cars.pop().unwrap();println!("{:?}", cars);println!("{:?}", car);//删除:固定index删除let car = cars.remove(0);println!("{:?}", cars);println!("{:?}", car);//队尾插入:pushcars.push(car.clone());println!("{:?}", cars);// 队首插入:insertcars.insert(0, car.clone());println!("{:?}", cars);// get set// 不推荐cars[9] = Car {id: 11,name: "car-11".to_string(),};println!("{:?}", cars);// 推荐let item = cars.get(0);println!("{:?}", item);let item = cars.get_mut(9).unwrap();*item = Car {id: 10,name: "car-10".to_owned(),};println!("{:?}", cars);let mut cars2 = vec![car.clone(), car.clone()];cars.append(&mut cars2);println!("{:?}", cars);println!("{:?}", cars2);let car_slice = cars.as_slice();println!("{:?}", car_slice);// 清理cars.clear();println!("{:?}", cars);println!("{:?}", cars.is_empty());
}

编译及运行

 cargo runCompiling data_struct v0.1.0 (/home/wangji/installer/rust/data_struct/data_struct)
warning: fields `id` and `name` are never read--> src/main.rs:3:5|
2 | struct Car {|        --- fields in this struct
3 |     id: i32,|     ^^
4 |     name: String,|     ^^^^|= note: `Car` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis= note: `#[warn(dead_code)]` on by defaultwarning: `data_struct` (bin "data_struct") generated 1 warningFinished `dev` profile [unoptimized + debuginfo] target(s) in 5.81sRunning `target/debug/data_struct`
[2,3,4,
]: 3
[2,2,2,
]: 3
[]: 0
[]: 5
[Car { id: 1, name: "bus-1" }, Car { id: 2, name: "car-2" }, Car { id: 3, name: "bus-3" }, Car { id: 4, name: "car-4" }, Car { id: 5, name: "bus-5" }, Car { id: 6, name: "car-6" }, Car { id: 7, name: "bus-7" }, Car { id: 8, name: "car-8" }, Car { id: 9, name: "bus-9" }, Car { id: 10, name: "car-10" }]
[Car { id: 1, name: "bus-1" }, Car { id: 2, name: "car-2" }, Car { id: 3, name: "bus-3" }, Car { id: 4, name: "car-4" }, Car { id: 5, name: "bus-5" }, Car { id: 6, name: "car-6" }, Car { id: 7, name: "bus-7" }, Car { id: 8, name: "car-8" }, Car { id: 9, name: "bus-9" }]
Car { id: 10, name: "car-10" }
[Car { id: 2, name: "car-2" }, Car { id: 3, name: "bus-3" }, Car { id: 4, name: "car-4" }, Car { id: 5, name: "bus-5" }, Car { id: 6, name: "car-6" }, Car { id: 7, name: "bus-7" }, Car { id: 8, name: "car-8" }, Car { id: 9, name: "bus-9" }]
Car { id: 1, name: "bus-1" }
[Car { id: 2, name: "car-2" }, Car { id: 3, name: "bus-3" }, Car { id: 4, name: "car-4" }, Car { id: 5, name: "bus-5" }, Car { id: 6, name: "car-6" }, Car { id: 7, name: "bus-7" }, Car { id: 8, name: "car-8" }, Car { id: 9, name: "bus-9" }, Car { id: 1, name: "bus-1" }]
[Car { id: 1, name: "bus-1" }, Car { id: 2, name: "car-2" }, Car { id: 3, name: "bus-3" }, Car { id: 4, name: "car-4" }, Car { id: 5, name: "bus-5" }, Car { id: 6, name: "car-6" }, Car { id: 7, name: "bus-7" }, Car { id: 8, name: "car-8" }, Car { id: 9, name: "bus-9" }, Car { id: 1, name: "bus-1" }]
[Car { id: 1, name: "bus-1" }, Car { id: 2, name: "car-2" }, Car { id: 3, name: "bus-3" }, Car { id: 4, name: "car-4" }, Car { id: 5, name: "bus-5" }, Car { id: 6, name: "car-6" }, Car { id: 7, name: "bus-7" }, Car { id: 8, name: "car-8" }, Car { id: 9, name: "bus-9" }, Car { id: 11, name: "car-11" }]
Some(Car { id: 1, name: "bus-1" })
[Car { id: 1, name: "bus-1" }, Car { id: 2, name: "car-2" }, Car { id: 3, name: "bus-3" }, Car { id: 4, name: "car-4" }, Car { id: 5, name: "bus-5" }, Car { id: 6, name: "car-6" }, Car { id: 7, name: "bus-7" }, Car { id: 8, name: "car-8" }, Car { id: 9, name: "bus-9" }, Car { id: 10, name: "car-10" }]
[Car { id: 1, name: "bus-1" }, Car { id: 2, name: "car-2" }, Car { id: 3, name: "bus-3" }, Car { id: 4, name: "car-4" }, Car { id: 5, name: "bus-5" }, Car { id: 6, name: "car-6" }, Car { id: 7, name: "bus-7" }, Car { id: 8, name: "car-8" }, Car { id: 9, name: "bus-9" }, Car { id: 10, name: "car-10" }, Car { id: 1, name: "bus-1" }, Car { id: 1, name: "bus-1" }]
[]
[Car { id: 1, name: "bus-1" }, Car { id: 2, name: "car-2" }, Car { id: 3, name: "bus-3" }, Car { id: 4, name: "car-4" }, Car { id: 5, name: "bus-5" }, Car { id: 6, name: "car-6" }, Car { id: 7, name: "bus-7" }, Car { id: 8, name: "car-8" }, Car { id: 9, name: "bus-9" }, Car { id: 10, name: "car-10" }, Car { id: 1, name: "bus-1" }, Car { id: 1, name: "bus-1" }]
[]
true

3.get()方法


#![allow(unused)]
fn main() {
let v = vec![1, 2, 3, 4, 5];let third: &i32 = &v[2];
println!("The third element is {}", third);match v.get(2) {Some(third) => println!("The third element is {}", third),None => println!("There is no third element."),
}
}
~/installer/rust/bobo/abc master 
 cargo runCompiling abc v0.1.0 (/home/wangji/installer/rust/bobo/abc)Finished `dev` profile [unoptimized + debuginfo] target(s) in 7.48sRunning `target/debug/abc`
The third element is 3
The third element is 3
~/installer/rust/bobo/abc master 
 

4.与枚举的结合


#![allow(unused)]
fn main() {enum SpreadsheetCell {Int(i32),Float(f64),Text(String),}let row = vec![SpreadsheetCell::Int(3),SpreadsheetCell::Text(String::from("blue")),SpreadsheetCell::Float(10.12),];match &row[1] {SpreadsheetCell::Int(i) => println!("Found an int: {}", i),_ => println!("No int found"),}
}

编译及运行

 cargo runCompiling abc v0.1.0 (/home/wangji/installer/rust/bobo/abc)Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.29sRunning `target/debug/abc`
No int found

二、VecDeque

一个双向的动态数组

与Vec 类似,与Vec 不同的是,它对容器的两端进行 移除和插入

VecDeque的两端插入、删除都是O(1)级别的

VecDeque并一定是连续的

1.什么情况适合VecDeque

有双端插入和删除需求的

双向需求queue

2.VecDeque的方法

继承了Vec的所有方法

自身的方法

push_back\push_front (取代了push)
pop_frontlpop_back(取代了pop)
contains
frontifront_mut
back\back_mut

Example:

use std::collections::VecDeque;
#[derive(Debug, Clone)]
struct Car {id: i32,name: String,
}fn main() {let mut int_queue: VecDeque<i32> = VecDeque::new();println!("{:?} cap {}", int_queue, int_queue.capacity());int_queue.push_back(3);println!("{:?} cap {}", int_queue, int_queue.capacity());let mut int_queue: VecDeque<i32> = VecDeque::with_capacity(20);println!("{:?} cap {}", int_queue, int_queue.capacity());let mut cars = VecDeque::from([Car {id: 1,name: String::from("Car-1"),},Car {id: 2,name: String::from("Car-2"),},Car {id: 3,name: String::from("Car-3"),},]);println!("{:?} cap {}", cars, cars.capacity());// VecDeque// pushcars.push_back(Car {id: 4,name: "Car-4".to_string(),});println!("{:?} cap {}", cars, cars.capacity());cars.push_front(Car {id: 0,name: "Car-0".to_string(),});println!("{:?} cap {}", cars, cars.capacity());// poplet back_car = cars.pop_back();println!("{:?}", back_car);println!("{:?} cap {}", cars, cars.capacity());let front_car = cars.pop_front();println!("{:?} ", front_car);println!("{:?} cap {}", cars, cars.capacity());// front// backprintln!("{:?}", cars.front());println!("{:?}", cars.back());// getprintln!("car{:?}", cars[1]); //不安全操作let car = cars.get(1).unwrap(); //安全操作println!("car{:?}", car);let car = cars.get_mut(1).unwrap();*car = Car {id: 10,name: "Car-n".to_owned(),};println!("car{:?}", cars);cars.clear();println!("{:?}", cars.is_empty());
}

编译及运行

 cargo runBlocking waiting for file lock on build directoryCompiling data_struct v0.1.0 (/home/wangji/installer/rust/data_struct/data_struct)
warning: variable does not need to be mutable--> src/main.rs:13:9|
13 |     let mut int_queue: VecDeque<i32> = VecDeque::with_capacity(20);|         ----^^^^^^^^^|         ||         help: remove this `mut`|= note: `#[warn(unused_mut)]` on by defaultwarning: fields `id` and `name` are never read--> src/main.rs:4:5|
3 | struct Car {|        --- fields in this struct
4 |     id: i32,|     ^^
5 |     name: String,|     ^^^^|= note: `Car` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis= note: `#[warn(dead_code)]` on by defaultwarning: `data_struct` (bin "data_struct") generated 2 warnings (run `cargo fix --bin "data_struct"` to apply 1 suggestion)Finished `dev` profile [unoptimized + debuginfo] target(s) in 8.30sRunning `target/debug/data_struct`
[] cap 0
[3] cap 4
[] cap 20
[Car { id: 1, name: "Car-1" }, Car { id: 2, name: "Car-2" }, Car { id: 3, name: "Car-3" }] cap 3
[Car { id: 1, name: "Car-1" }, Car { id: 2, name: "Car-2" }, Car { id: 3, name: "Car-3" }, Car { id: 4, name: "Car-4" }] cap 6
[Car { id: 0, name: "Car-0" }, Car { id: 1, name: "Car-1" }, Car { id: 2, name: "Car-2" }, Car { id: 3, name: "Car-3" }, Car { id: 4, name: "Car-4" }] cap 6
Some(Car { id: 4, name: "Car-4" })
[Car { id: 0, name: "Car-0" }, Car { id: 1, name: "Car-1" }, Car { id: 2, name: "Car-2" }, Car { id: 3, name: "Car-3" }] cap 6
Some(Car { id: 0, name: "Car-0" }) 
[Car { id: 1, name: "Car-1" }, Car { id: 2, name: "Car-2" }, Car { id: 3, name: "Car-3" }] cap 6
Some(Car { id: 1, name: "Car-1" })
Some(Car { id: 3, name: "Car-3" })
carCar { id: 2, name: "Car-2" }
carCar { id: 2, name: "Car-2" }
car[Car { id: 1, name: "Car-1" }, Car { id: 10, name: "Car-n" }, Car { id: 3, name: "Car-3" }]
true

三、LinkedList

通过链式存储数据的一种序列数据结构

A double-linked with owned nodes

1.什么时候用LinkedList

·根据Rust文档,LinkedList数据结构在分割/追加方面是高效的

如果您希望对分配多少内存以及何时分配内存有非常细粒度的控制,那么链表是一个不错的选择。但是绝大多数你用不到,而且你要考虑成本

use std::collections::LinkedList;#[derive(Debug, Clone)]
struct Car {id: i32,name: String,
}
// vecque 方法都有
// vec 无
fn main() {let mut int_link: LinkedList<i32> = LinkedList::new();let mut cars = LinkedList::from([Car {id: 1,name: "Car-1".to_string(),},Car {id: 2,name: "Car-2".to_string(),},Car {id: 3,name: "Car-3".to_string(),},]);cars.push_back(Car {id: 4,name: "Car-4".to_string(),});println!("back: {:?}", cars.back());cars.push_front(Car {id: 0,name: "Car-0".to_string(),});println!("front: {:?}", cars.front());println!("{:?}", cars);let car = cars.pop_back().unwrap();println!("{:?}", car);let car = cars.pop_front().unwrap();println!("{:?}", car);/*** split_off 是一个方法,用于将 Vec 切成两部分。它会将 cars 向量从指定的索引位置分成两部分,并返回从该位置开始的所有元素,同时将这些元素从原向量中移除。*/let mut car_list = cars.split_off(cars.len() - 2);println!("---{:?}", car_list);println!("{:?}", cars);cars.append(&mut car_list);println!("{:?}", cars);println!("{:?}", car_list);cars.clear();println!("{}", cars.is_empty());
}

编译及运行:

 cargo runCompiling data_struct v0.1.0 (/home/wangji/installer/rust/data_struct/data_struct)
warning: unused doc comment--> src/main.rs:44:5|
44 | /     /**
45 | |      * split_off 是一个方法,用于将 Vec 切成两部分。它会将 cars 向量从指定的索引位置分成两部分,并返回从该位置开始的所有元素,同时将这些元素从原向量中移除。
46 | |      */| |_______^
47 |       let mut car_list = cars.split_off(cars.len() - 2);|       -------------------------------------------------- rustdoc does not generate documentation for statements|= help: use `/* */` for a plain comment= note: `#[warn(unused_doc_comments)]` on by defaultwarning: unused variable: `int_link`--> src/main.rs:11:13|
11 |     let mut int_link: LinkedList<i32> = LinkedList::new();|             ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_int_link`|= note: `#[warn(unused_variables)]` on by defaultwarning: variable does not need to be mutable--> src/main.rs:11:9|
11 |     let mut int_link: LinkedList<i32> = LinkedList::new();|         ----^^^^^^^^|         ||         help: remove this `mut`|= note: `#[warn(unused_mut)]` on by defaultwarning: fields `id` and `name` are never read--> src/main.rs:5:5|
4 | struct Car {|        --- fields in this struct
5 |     id: i32,|     ^^
6 |     name: String,|     ^^^^|= note: `Car` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis= note: `#[warn(dead_code)]` on by defaultwarning: `data_struct` (bin "data_struct") generated 4 warnings (run `cargo fix --bin "data_struct"` to apply 1 suggestion)Finished `dev` profile [unoptimized + debuginfo] target(s) in 6.13sRunning `target/debug/data_struct`
back: Some(Car { id: 4, name: "Car-4" })
front: Some(Car { id: 0, name: "Car-0" })
[Car { id: 0, name: "Car-0" }, Car { id: 1, name: "Car-1" }, Car { id: 2, name: "Car-2" }, Car { id: 3, name: "Car-3" }, Car { id: 4, name: "Car-4" }]
Car { id: 4, name: "Car-4" }
Car { id: 0, name: "Car-0" }
---[Car { id: 2, name: "Car-2" }, Car { id: 3, name: "Car-3" }]
[Car { id: 1, name: "Car-1" }]
[Car { id: 1, name: "Car-1" }, Car { id: 2, name: "Car-2" }, Car { id: 3, name: "Car-3" }]
[]
true

参考

  • Rust常用数据结构教程

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/466832.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

基于IM场景下的Wasm初探:提升Web应用性能|得物技术

一、何为Wasm &#xff1f; Wasm&#xff0c;全称 WebAssembly&#xff0c;官网描述是一种用于基于堆栈的虚拟机的二进制指令格式。Wasm被设计为一个可移植的目标&#xff0c;用于编译C/C/Rust等高级语言&#xff0c;支持在Web上部署客户端和服务器应用程序。 Wasm 的开发者参…

基于百度飞桨paddle的paddlepaddle2.4.2等系列项目的运行

PPASR 必看&#xff01;&#xff01;&#xff01; PaddleSpeech develop --> PaddlePaddle 2.5.0/2.5.1 PaddleSpeech < 1.4.1 --> PaddlePaddle < 2.4.2 1.创建虚拟环境 conda create --name test python3.10 2.激活环境&#xff0c;安装ppasr的paddlepaddl…

2024MoonBit全球编程创新挑战赛参赛作品“飞翔的小鸟”技术开发指南

本文转载自 CSDN&#xff1a;https://blog.csdn.net/m0_61243965/article/details/143510089作者&#xff1a;言程序plus 实战开发基于moonbit和wasm4的飞翔的小鸟游戏 游戏中&#xff0c;玩家需要通过上下左右按键控制Bird&#xff0c;在不断移动的障碍pipe之间穿梭&#xf…

浅谈Agent

目录 什么是大模型 Agent &#xff1f; 大模型Agent 有哪些部分组成? 规划&#xff08;Planning&#xff09; Planning类型 不依赖反馈的计划 基于反馈的计划 拆解子目标和任务分解方法 COT TOT GOT LLMP 反思和完善 ReAct(融合推理与执行的能力) Reflexion(动态…

文本转SQL(Text-to-SQL),场景介绍与 Spring AI 实现

在众多的 AI 大模型的应用场景中&#xff0c;Text-to-SQL&#xff0c;也就是文本转 SQL&#xff0c;是其中实用性很高的一个。Text-to-SQL 充分利用了大模型的优势&#xff0c;把用户提供的自然语言描述转换成 SQL 语句&#xff0c;还可以执行生成的 SQL 语句&#xff0c;再把查…

DICOM标准:深入详解DICOM医学影像中的传输语法

引言 DICOM&#xff08;数字成像和通信医学&#xff09;标准在医学影像数据交换中扮演着至关重要的角色。其中&#xff0c;*传输语法&#xff08;Transfer Syntax&#xff09;是DICOM标准中定义数据编码和传输方式的核心部分。理解传输语法对于确保不同设备和系统之间的互操作性…

如何提高谷歌收录速度?

相信很多做外贸推广的朋友都遇到过这种情况&#xff1a;网站上线了&#xff0c;但新页面迟迟不被谷歌收录。即使你的内容很优秀&#xff0c;设计也很精美&#xff0c;如果谷歌爬虫抓不到页面&#xff0c;一切努力就白费了。这时候&#xff0c;GSI谷歌快速收录服务就成了“救命稻…

Spring面向切面编程

目录 1.AOP概述及Spring AOP实现原理 AOP概述 AOP的应用场景 AOP的作用 Spring AOP概述 Spring AOP的实现原理 Spring AOP中Advice的分类 2. 通过xml配置实现AOP 实现步骤&#xff1a; 新增模块&#xff1a; 导入相关依赖&#xff1a; 新增实体类User 新增业务类UserS…

Notepad++ 更改字体大小和颜色

前言 在长时间编程或文本编辑过程中&#xff0c;合适的字体大小和颜色可以显著提高工作效率和减少眼睛疲劳。Notepad 提供了丰富的自定义选项&#xff0c;让你可以根据个人喜好调整编辑器的外观。 步骤详解 1. 更改字体大小 打开 Notepad 启动 Notepad 编辑器。 进入设置菜…

香港航空 阿里滑块 acw_sc__v3 分析

声明: 本文章中所有内容仅供学习交流使用&#xff0c;不用于其他任何目的&#xff0c;抓包内容、敏感网址、数据接口等均已做脱敏处理&#xff0c;严禁用于商业用途和非法用途&#xff0c;否则由此产生的一切后果均与作者无关&#xff01; 有相关问题请第一时间头像私信联系我删…

Unet++改进3:添加NAMAttention注意力机制

本文内容:添加NAMAttention注意力机制 目录 论文简介 1.步骤一 2.步骤二 3.步骤三 4.步骤四 论文简介 识别不太显著的特征是模型压缩的关键。然而,它在革命性的注意机制中尚未得到研究。在这项工作中,我们提出了一种新的基于归一化的注意力模块(NAM),它抑制了较不显著…

WPF+MVVM案例实战(二十二)- 制作一个侧边弹窗栏(CD类)

文章目录 1、案例效果1、侧边栏分类2、CD类侧边弹窗实现1、样式代码实现2、功能代码实现3 运行效果4、源代码获取1、案例效果 1、侧边栏分类 A类 :左侧弹出侧边栏B类 :右侧弹出侧边栏C类 :顶部弹出侧边栏D类 :底部弹出侧边栏2、CD类侧边弹窗实现 1、样式代码实现 在原有的…

汽车广告常见特效处理有哪些?

​汽车广告作为展示汽车性能和外观的重要媒介&#xff0c;常常需要借助特效来增强视觉效果&#xff0c;吸引观众的注意力。以下是一篇关于汽车广告中常见特效处理的文章。 在竞争激烈的汽车市场中&#xff0c;广告不仅是推广产品的工具&#xff0c;更是艺术和科技的结合。特效技…

【CUDA】线程配置

一、 线程层次结构 1.1 认识 GPU 可并行执行工作 Thread&#xff1a;所有线程执行相同的核函数&#xff0c;并行执行 Thread Block&#xff1a;执行在一个Streaming Multiprocessor (SM)&#xff0c;同一个Block中的线程可以协作 线程的集合称为块&#xff0c;块的数量很多…

爬虫-------字体反爬

目录 一、了解什么是字体加密 二. 定位字体位置 三. python处理字体 1. 工具库 2. 字体读取 3. 处理字体 案例1&#xff1a;起点 案例2&#xff1a;字符偏移&#xff1a; 5请求数据 - 发现偏移量 5.4 多套字体替换 套用模板 版本1 版本2 四.项目实战 1. 采集目…

transformer模型写诗词

项目源码获取方式见文章末尾&#xff01; 600多个深度学习项目资料&#xff0c;快来加入社群一起学习吧。 《------往期经典推荐------》 项目名称 1.【基于CNN-RNN的影像报告生成】 2.【卫星图像道路检测DeepLabV3Plus模型】 3.【GAN模型实现二次元头像生成】 4.【CNN模型实现…

【计算机网络】章节 知识点总结

一、计算机网络概述 1. 计算机网络向用户提供的两个最重要的功能&#xff1a;连通性、共享 2. 因特网发展的三个阶段&#xff1a; 第一阶段&#xff1a;从单个网络 ARPANET 向互联网发展的过程。1983 年 TCP/IP 协议成为 ARPANET 上的标准协议。第二阶段&#xff1a;建成三级…

【微服务】不同微服务之间用户信息的获取和传递方案

如何才能在每个微服务中都拿到用户信息&#xff1f;如何在微服务之间传递用户信息&#xff1f; 文章目录 概述利用微服务网关做登录校验网关转微服务获取用户信息openFeign传递微服务之间的用户信息 概述 要在每个微服务中获取用户信息&#xff0c;可以采用以下几种方法&#…

【p2p、分布式,区块链笔记 Torrent】WebTorrent 的lt_donthave插件

扩展实现 https://github.com/webtorrent/lt_donthave/blob/master/index.js /*! lt_donthave. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */// 导入所需模块 import arrayRemove from unordered-array-remove // 用于从数组中删除元素的函数 i…

兰空图床配置域名访问

图床已经创建完毕并且可以访问了&#xff0c;但是使用IP地址多少还是差点意思&#xff0c;而且不方便记忆&#xff0c;而NAT模式又没法直接像普通服务器一样DNS解析完就可以访问。 尝试了很多办法&#xff0c;nginx配置了半天也没配好&#xff0c;索性直接重定向&#xff0c;反…