详解Rust标准库:VecDeque 队列


theme: github
highlight: an-old-hope

查看本地官方文档

安装rust后运行

rustup doc

查看The Standard Library即可获取标准库内容

std::connections::VecDeque定义

队列是遵循先入先出规则的线性数据结构,在内存中不一定连续

VecDeque定义:可增长的环形缓冲区实现的双端队列

pub struct VecDeque<T, A: Allocator = Global> {// 队列头部在内部缓冲区中的索引位置head: usize,// 当前队列中的元素数量len: usize,// 管理内存分配和释放,确保有足够的空间来存储队列中的元素buf: RawVec<T, A>,
}

方法

with_capacity:用于创建一个具有指定初始容量的VecDeque

use std::collections::VecDeque;fn main() {let deque = VecDeque::from([1, 2, 3]);if let Some(element) = deque.get(1) {println!("Element at index 1: {}", element);// Element at index 1: 2}
}

get:获取指定索引位置的元素的不可变引用

use std::collections::VecDeque;fn main() {let deque = VecDeque::from([1, 2, 3]);if let Some(element) = deque.get(1) {println!("Element at index 1: {}", element);// Element at index 1: 2}
}

get_mut:获取指定索引位置的元素的可变引用

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3]);if let Some(element) = deque.get_mut(1) {*element = 4;}println!("Modified deque: {:?}", deque);// Modified deque: [1, 4, 3]
}

swap:交换VecDeque中两个指定索引位置的元素

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3]);deque.swap(0, 2);println!("Swapped deque: {:?}", deque);// Swapped deque: [3, 2, 1]
}

capacity:返回VecDeque当前的容量

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::with_capacity(5);println!("Initial capacity: {}", deque.capacity());// Initial capacity: 5deque.push_back(1);println!("Capacity after adding an element: {}", deque.capacity());// Capacity after adding an element: 5
}

reserve_exact:精确地预留足够的空间以容纳指定数量的额外元素

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::new();deque.reserve_exact(3);println!("Capacity after reserve_exact: {}", deque.capacity());// Capacity after reserve_exact: 3deque.push_back(1);deque.push_back(2);deque.push_back(3);
}

reserve:预留足够的空间以容纳指定数量的额外元素(空间不够自动增长)

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::new();deque.reserve(5);println!("Capacity after reserve: {}", deque.capacity());// Capacity after reserve: 5deque.push_back(1);deque.push_back(2);deque.push_back(3);deque.push_back(4);deque.push_back(5);deque.push_back(6);println!("Capacity after reserve: {}", deque.capacity());// Capacity after reserve: 10
}

try_reserve_exact:尝试精确地预留足够的空间以容纳指定数量的额外元素,如果预留成功则返回Ok(()),否则返回错误

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::new();if let Ok(()) = deque.try_reserve_exact(3) {println!("Reserved successfully. Capacity: {}", deque.capacity());// Reserved successfully. Capacity: 3} else {println!("Reserve failed.");}deque.push_back(1);deque.push_back(2);deque.push_back(3);deque.push_back(4);println!("Reserved successfully. Capacity: {}", deque.capacity());// Reserved successfully. Capacity: 6
}

try_reserve:尝试预留足够的空间以容纳指定数量的额外元素,如果预留成功则返回Ok(()),否则返回错误

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::new();if let Ok(()) = deque.try_reserve(3) {println!("Reserved successfully. Capacity: {}", deque.capacity());// Reserved successfully. Capacity: 4} else {println!("Reserve failed.");}deque.push_back(1);deque.push_back(2);deque.push_back(3);deque.push_back(4);
}

shrink_to_fit:将VecDeque的容量收缩到与当前元素数量相同

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::with_capacity(10);deque.push_back(1);deque.push_back(2);deque.push_back(3);deque.shrink_to_fit();println!("Capacity after shrink_to_fit: {}", deque.capacity());// Capacity after shrink_to_fit: 3
}

shrink_to:将VecDeque的容量收缩到指定大小

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::with_capacity(10);deque.push_back(1);deque.push_back(2);deque.push_back(3);deque.shrink_to(5);println!("Capacity after shrink_to: {}", deque.capacity());// Capacity after shrink_to: 5
}

truncate:将VecDeque截断到指定长度

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3, 4, 5]);deque.truncate(3);println!("Truncated deque: {:?}", deque);// Truncated deque: [1, 2, 3]
}

iter:返回一个不可变的迭代器,用于遍历VecDeque中的元素

use std::collections::VecDeque;fn main() {let deque = VecDeque::from([1, 2, 3]);for element in deque.iter() {println!("Element: {}", element);}// Element: 1// Element: 2// Element: 3
}

iter_mut:返回一个可变的迭代器,允许在遍历过程中修改VecDeque中的元素

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3]);for element in deque.iter_mut() {*element *= 2;}println!("Modified deque: {:?}", deque);// Modified deque: [2, 4, 6]
}

as_slice:将VecDeque分成不可变的切片

use std::collections::VecDeque;fn main() {let deque = VecDeque::from([1, 2, 3, 4, 5]);let (front_slice, back_slice) = deque.as_slices();println!("Front slice: {:?}", front_slice);// Front slice: [1, 2, 3, 4, 5]println!("Back slice: {:?}", back_slice);// Back slice: []
}

as_mut_slices:将VecDeque分成可变的切片

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3, 4, 5]);let (front_slice, back_slice) = deque.as_mut_slices();for element in front_slice {*element *= 2;}for element in back_slice {*element *= 3;}println!("Modified deque: {:?}", deque);// Modified deque: [2, 4, 6, 8, 10]
}

len:返回VecDeque中元素的数量

use std::collections::VecDeque;fn main() {let deque = VecDeque::from([1, 2, 3]);println!("Length of deque: {}", deque.len());// Length of deque: 3
}

is_empty:判断VecDeque是否为空

use std::collections::VecDeque;fn main() {let deque:VecDeque<i32> = VecDeque::new();println!("Is deque empty? {}", deque.is_empty());// Is deque empty? truelet deque2 = VecDeque::from([1]);println!("Is deque2 empty? {}", deque2.is_empty());// Is deque2 empty? false
}

range:返回一个指定范围内的不可变迭代器

use std::collections::VecDeque;fn main() {let deque = VecDeque::from([1, 2, 3, 4, 5]);for element in deque.range(1..3) {println!("Element: {}", element);// Element: 2// Element: 3}
}

range_mut:返回一个指定范围内的可变迭代器

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3, 4, 5]);for element in deque.range_mut(1..3) {*element *= 2;}println!("Modified deque: {:?}", deque);// Modified deque: [1, 4, 6, 4, 5]
}

drain:移除并返回一个迭代器,用于遍历被移除的元素

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3, 4, 5]);let drained = deque.drain(1..3).collect::<Vec<i32>>();println!("Drained elements: {:?}", drained);// Drained elements: [2, 3]println!("Remaining deque: {:?}", deque);// Remaining deque: [1, 4, 5]
}

clear:清空VecDeque,移除所有元素

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3]);println!("Before clearing: {:?}", deque);// Before clearing: [1, 2, 3]deque.clear();println!("After clearing: {:?}", deque);// After clearing: []
}

contains:判断VecDeque中是否包含特定元素

use std::collections::VecDeque;fn main() {let deque = VecDeque::from([1, 2, 3]);println!("Does deque contain 2? {}", deque.contains(&2));// Does deque contain 2? trueprintln!("Does deque contain 4? {}", deque.contains(&4));// Does deque contain 4? false
}

front:返回VecDeque头部元素的不可变引用,如果为空则返回None

use std::collections::VecDeque;fn main() {let deque = VecDeque::from([1, 2, 3]);if let Some(element) = deque.front() {println!("Front element: {}", element);// Front element: 1}
}

front_mut:返回VecDeque头部元素的可变引用,如果为空则返回None

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3]);if let Some(element) = deque.front_mut() {*element = 4;}println!("Modified deque: {:?}", deque);// Modified deque: [4, 2, 3]
}

back:返回VecDeque尾部元素的不可变引用,如果为空则返回None

use std::collections::VecDeque;fn main() {let deque = VecDeque::from([1, 2, 3]);if let Some(element) = deque.back() {println!("Back element: {}", element);// Back element: 3}
}

back_mut:返回VecDeque尾部元素的可变引用,如果为空则返回None

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3]);if let Some(element) = deque.back_mut() {*element = 4;}println!("Modified deque: {:?}", deque);// Modified deque: [1, 2, 4]
}

pop_front:移除并返回VecDeque头部元素,如果为空则返回None

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3]);if let Some(element) = deque.pop_front() {println!("Popped element: {}", element);// Popped element: 1}println!("Remaining deque: {:?}", deque);// Remaining deque: [2, 3]
}

pop_back:移除并返回VecDeque尾部元素,如果为空则返回None

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3]);if let Some(element) = deque.pop_back() {println!("Popped element: {}", element);// Popped element: 3}println!("Remaining deque: {:?}", deque);// Remaining deque: [1, 2]
}

push_front:在VecDeque头部插入一个元素

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::new();deque.push_front(1);deque.push_front(2);println!("Modified deque: {:?}", deque);// Modified deque: [2, 1]
}

push_back:在VecDeque尾部插入一个元素

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::new();deque.push_back(1);deque.push_back(2);println!("Modified deque: {:?}", deque);// Modified deque: [1, 2]
}

swap_remove_front:移除并返回VecDeque头部开始的元素索引,同时用其后的第一个元素替换它,避免移动其后的所有元素,如果为空则返回None

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3, 4]);if let Some(element) = deque.swap_remove_front(2) {println!("Swapped and removed element: {}", element);// Swapped and removed element: 3}println!("Remaining deque: {:?}", deque);// Remaining deque: [2, 1, 4]
}

swap_remove_back:移除并返回VecDeque尾部开始的元素索引,同时用前一个元素替换它,避免移动前面的所有元素,如果为空则返回None

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3, 4]);if let Some(element) = deque.swap_remove_back(2) {println!("Swapped and removed element from back: {}", element);// Swapped and removed element from back: 3}println!("Remaining deque: {:?}", deque);// Remaining deque: [1, 2, 4]
}

insert:在指定索引位置插入一个元素。如果索引超出范围,会导致程序 panic(元素为[1,2,3]时容量为3,插入索引1不改变容量,插入4时由于索引是连续的,会开辟原队列的两倍容量6,后续插入索引5可以成功,如果直接插入5索引不连续不会开辟新空间会panic

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3]);println!("deque capacity: {}", deque.capacity());// deque capacity: 3deque.insert(1, 9);// deque.insert(4, 5); // 这一行存在以下操作成功,不存在 panic!deque.insert(5, 6); // panic!'println!("deque capacity: {}", deque.capacity());// deque capacity: 6println!("After insertion: {:?}", deque);// After insertion: [1, 9, 2, 4, 3, 6]println!("deque capacity: {}", deque.capacity());// deque capacity: 6
}

remove:移除指定索引位置的元素,并返回该元素。如果索引超出范围,会导致程序 panic

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3]);if let Some(element) = deque.remove(1) {println!("Removed element: {}", element);// Removed element: 2}println!("Remaining deque: {:?}", deque);// Remaining deque: [1, 3]
}

split_off:在指定索引位置将VecDeque分割成两个,返回从指定索引开始的后半部分

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3, 4, 5]);let deque2 = deque.split_off(2);println!("{:?}", deque2);// [3, 4, 5]
}

append:将另一个VecDeque的所有元素追加到当前VecDeque的末尾

use std::collections::VecDeque;fn main() {let mut deque1 = VecDeque::from([1, 2, 3]);let mut deque2 = VecDeque::from([4, 5, 6]);deque1.append(&mut deque2);println!("Appended deque: {:?}", deque1);// Appended deque: [1, 2, 3, 4, 5, 6]
}

retain:保留满足给定谓词的元素,移除不满足的元素

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3, 4, 5]);deque.retain(|&x| x % 2 == 0);println!("After retain: {:?}", deque);// After retain: [2, 4]
}

retain_mut:与retain类似,但可以对元素进行可变操作

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3, 4, 5]);deque.retain_mut(|x| {*x *= 2;*x % 3 == 0});println!("After retain_mut: {:?}", deque);// After retain_mut: [6]
}

resize_with:调整VecDeque的大小到指定长度,使用给定的函数生成新元素填充额外的空间或者截断多余的元素

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2]);deque.resize_with(5, || 0);println!("Resized deque: {:?}", deque);// Resized deque: [1, 2, 0, 0, 0]
}

make_contiguous:尝试使VecDeque在内存中连续存储,可能会导致重新分配内存

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3]);deque.make_contiguous();println!("After make_contiguous: {:?}", deque);// After make_contiguous: [1, 2, 3]
}

rotate_left:将VecDeque向左旋转指定的步数

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3, 4, 5]);deque.rotate_left(2);println!("After rotate_left: {:?}", deque);// After rotate_left: [3, 4, 5, 1, 2]
}

rotate_right:将VecDeque向右旋转指定的步数

use std::collections::VecDeque;fn main() {let mut deque = VecDeque::from([1, 2, 3, 4, 5]);deque.rotate_right(2);println!("After rotate_right: {:?}", deque);// After rotate_right: [4, 5, 1, 2, 3]
}

binary_search:在已排序VecDeque中进行二分查找指定元素,返回一个Result类型,表示查找结果。如果找到元素,返回Ok(index),默认最后一个结果;如果未找到返回Err();在未排序的队列进行查找会返回unspecified,这个结果没有意义

当查找的元素不存在时返回查找元素应当插入位置有序队列位置的索引

当查找的元素存在时返回最后一个匹配的元素

use std::collections::VecDeque;fn main() {let deque = VecDeque::from([1, 2, 3, 3, 4, 5]);let result = deque.binary_search(&3);println!("{:?}", result);// Ok(3)// 有序且不存在let deque = VecDeque::from([3, 3, 3, 3, 3, 4, 4, 7, 8]);let result = deque.binary_search(&5);println!("{:?}", result);// Err(7)// 有序且存在let deque = VecDeque::from([3, 3, 3, 3, 3, 4, 4, 7, 8]);let result = deque.binary_search(&3);println!("{:?}", result);// Ok(4)// 注意以下结果没有意义// 无序且不存在let deque = VecDeque::from([3, 9, 3, 3, 8, 4, 3, 7, 3]);let result = deque.binary_search(&5);println!("{:?}", result);// Err(4)// 无序且存在let deque = VecDeque::from([3, 9, 3, 3, 8, 4, 3, 7, 3]);let result = deque.binary_search(&3);println!("{:?}", result);// Ok(2)
}

binary_search_by:使用自定义的比较函数在已排序VecDeque中进行二分查找

use std::collections::VecDeque;fn main() {let deque = VecDeque::from([1, 2, 3, 3, 4, 6]);// 找到最后一个等于3的元素索引let result = deque.binary_search_by(|x| x.cmp(&3));println!("{:?}", result);// Ok(3)// 找到最后一个等于5de的元素索引,不存在返回应当插入位置的索引let result = deque.binary_search_by(|x| x.cmp(&5));println!("{:?}", result);// Err(5)
}

binary_search_by_key:如果队列是以元组键的顺序排序的,使用自定义的键提取函数在已排序VecDeque中进行二分查找

use std::collections::VecDeque;fn main() {let deque = VecDeque::from([(0, 0),(2, 1),(4, 1),(5, 1),(3, 1),(1, 2),(2, 3),(4, 5),(5, 8),(3, 13),(1, 21),(2, 34),(4, 55),]);// 按元组第二个键值排序let result = deque.binary_search_by_key(&13, |&(a, b)| b);println!("{:?}", result);// Ok(9)
}

partition_point:在已排序的VecDeque中找到满足给定谓词的元素的分界点。即返回第一个不满足谓词的元素的索引

use std::collections::VecDeque;fn main() {let deque: VecDeque<i32> = VecDeque::from([1, 2, 3, 3, 5, 6, 7]);// 按小于5的元素划分,返回第一个大于等于5的索引let result = deque.partition_point(|&x| x < 5);println!("{:?}", result);// 4
}

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

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

相关文章

QML项目实战:自定义Combox

目录 一.添加模块 import QtQuick.Controls 2.4 import QtQuick.Templates 2.4 as T import QtGraphicalEffects 1.15 import QtQuick 2.15 as T2 二.自定义Combox 1.combox文字显示 2.设置下拉图标显示 3.下拉框中选中背景设置 4.下拉框中选中文字设置 5.下拉框设置…

招聘系统哪个最好用?

在当今竞争激烈的商业环境中&#xff0c;企业为了保持竞争优势&#xff0c;对人才的需求愈发迫切。然而&#xff0c;面对海量的简历和繁杂的招聘流程&#xff0c;如何高效、精准地找到合适的人才&#xff0c;成为许多企业面临的难题。招聘系统因此应运而生&#xff0c;为企业提…

基于C语言实现的图书管理系统

使用Visual Studio 2022编译工具进行编写代码的。 项目源码直接奉上: book1.h头文件: #ifndef __BOOK1_H //预处理用于条件编译 避免头文件反复包含 #define __BOOK1_H#include<stdio.h> #include <string.h> #include<stdlib.h> #include<stdbool.h&g…

带你用Go实现二维码小游戏(下)

本篇文章我们进入项目最后的部署和监控搭建阶段&#xff0c;这一节会有很少的编码量&#xff0c;但是却能够带来最实用的知识和技术&#xff0c;快来阅读吧~ 5 Docker镜像打包部署 接下来就到了我们项目的部署阶段&#xff0c;优雅的项目必须要搭配优雅的部署方式&#xff01…

Sigrity Power SI 3D-EM Inductance Extraction模式如何进行电感的提取操作指导(一)

Sigrity Power SI 3D-EM Inductance Extraction模式如何进行电感的提取操作指导(一) Sigrity Power SI使用3D-EM Inductance Extraction模式可以进行电感的提取,以下图为例 2D 视图 <

shodan6-7---清风

shodan6-7 1.shodan网页版 以cve-2019-0708漏洞指纹特征为例 "\x03\x00\x00\x0b\x06\xd0\x00\x00\x124\x00"在这里插入图片描述 搜索命令参考 https://www.shodan.io/search/filters这个网页中有搜索关键词 对指定网址进行监控&#xff0c;这里可以对ip进行扫描&…

CPU算法分析LiteAIServer视频智能分析平台视频智能分析:抖动、过亮与过暗检测技术

随着科技的飞速发展&#xff0c;视频监控系统在各个领域的应用日益广泛。然而&#xff0c;视频质量的好坏直接影响到监控系统的效能&#xff0c;尤其是在复杂多变的光照条件下和高速数据传输中&#xff0c;视频画面常常出现抖动、过亮或过暗等问题&#xff0c;导致监控视频难以…

win11电脑无法找到声音输出设备怎么办?查看解决方法

电脑无法找到声音输出设备是一个常见的问题&#xff0c;尤其是在使用Windows操作系统时。幸运的是&#xff0c;大部分问题都可以通过以下几种方法来解决。 一、检查物理连接 在深入诊断之前&#xff0c;首先要检查硬件连接是否正常。这包括&#xff1a; 确保耳机、扬声器或其…

JS数据结构之“栈”、“队列”、“链表”

一、栈 JS中没有栈这种数据类型&#xff0c;创建栈其实是创建数组。push&#xff08;内容&#xff09;入栈&#xff1b;pop&#xff08;&#xff09;出栈&#xff1b; const stack []; stack.push(1); stack.push(2); const item1 stack.pop(); const item2 stack.pop(); …

【51单片机】串口通信原理 + 使用

学习使用的开发板&#xff1a;STC89C52RC/LE52RC 编程软件&#xff1a;Keil5 烧录软件&#xff1a;stc-isp 开发板实图&#xff1a; 文章目录 串口硬件电路UART串口相关寄存器 编码单片机通过串口发送数据电脑通过串口发送数据控制LED灯 串口 串口是一种应用十分广泛的通讯接…

嵌入式web开发:boa、lighttpd

嵌入式web开发&#xff1a;boa、lighttpd https://blog.csdn.net/m0_37105371/category_10937068.html BOA服务器的移植-CSDN博客 【第1部分&#xff1a;boa服务器部署到ubuntu里】 http://www.boa.org/boa-0.94.13.tar.gz tar xvzf boa-0.94.13.tar.gz cd boa-0.94.13/src/ a…

RC高通滤波器Bode图分析(传递函数零极点)

RC高通滤波器 我们使得R1K&#xff0c;C1uF&#xff1b;电容C的阻抗为Xc&#xff1b; 传递函数 H ( s ) u o u i R X C R R 1 s C R s R C 1 s R C &#xff08;其中 s j ω &#xff09; H(s)\frac{u_{o} }{u_{i} } \frac{R }{X_{C}R} \frac{R }{\frac{1}{sC}R} \fra…

Python决策树、随机森林、朴素贝叶斯、KNN(K-最近邻居)分类分析银行拉新活动挖掘潜在贷款客户附数据代码

Python决策树、随机森林、朴素贝叶斯、KNN&#xff08;K-最近邻居&#xff09;分类分析银行拉新活动挖掘潜在贷款客户|附数据代码 最近我们被客户要求撰写关于银行拉新活动的研究报告&#xff0c;包括一些图形和统计输出。 项目背景&#xff1a;银行的主要盈利业务靠的是贷款&…

撰写开发信利器,高效工具助你赢在起点

ZohoCampaigns是电子邮件营销平台&#xff0c;提供创建、发送和分析邮件方案。其优势包括易用性、丰富模板、精准筛选、自动化和详细报告。外贸人员可用其高效发送开发信&#xff0c;追踪效果并优化策略&#xff0c;促进业务增长。 一、为什么选择Zoho Campaigns&#xff1f; …

协程5 --- 栈切换

文章目录 ucontext相关函数例子ucontext_t结构 setjump、longjump相关函数例子jmp_buf结构 汇编实现解析图示 ucontext 相关函数 #include <ucontext.h> int getcontext(ucontext_t *ucp);初始化ucp结构体&#xff0c;将当前上下文保存在ucp中。 int setcontext(const …

【Linux】Pinctrl子系统和GPIO子系统

Pinctrl子系统 在许多soc内部包含了多个pin控制器&#xff0c;通过pin控制器的寄存器&#xff0c;我们可以配置一个或者一组引脚的功能和特性。Linux内核为了统一各soc厂商的pin脚管理&#xff0c;提供了pinctrl子系统。该系统的作用&#xff1a; 在系统初始化的时候&#xf…

《Vue3 报错》Uncaught TypeError: s.finally is not a function

解决方案&#xff1a; 新建文件 my-polyfill.js // 当浏览器环境不支持Promise.prototype.finally if (!Promise.prototype[finally]) {Promise.prototype[finally] function(callback) {let P this.constructor;return this.then(value > P.resolve(callback()).then(…

RabbitMQ 七种工作模式介绍

目录 1.简单模式队列 2.WorkQueue(⼯作队列) 3 Publish/Subscribe(发布/订阅) 4 Routing(路由模式) 5.Topics(通配符模式) 6 RPC(RPC通信) 7 Publisher Confirms(发布确认) RabbitMQ 共提供了7种⼯作模式供我们进⾏消息传递,接下来一一介绍它的实现与目的 1.简单模式队列…

数组类算法【leetcode】

704. 二分查找 给定一个 n 个元素有序的&#xff08;升序&#xff09;整型数组 nums 和一个目标值 target &#xff0c;写一个函数搜索 nums 中的 target&#xff0c;如果目标值存在返回下标&#xff0c;否则返回 -1。 二分查找 用于有序数组中&#xff0c;没有重复的数组。…

Pandas 数据分析工具详细教程

Pandas 数据分析工具详细教程 Pandas 是一个强大的 Python 数据分析库&#xff0c;广泛应用于数据科学、数据分析和机器学习等领域。它提供了高效的数据操作和分析功能&#xff0c;使得数据处理变得简单而高效。本文将详细介绍 Pandas 的基本概念、数据结构、常用操作及其在数…