当前位置: 首页 > news >正文

容器库(5)-std::list

std::forward_list是可以从任何位置快速插入和移除元素的容器,不支持快速随机访问,支持正向和反向的迭代。

本文章的代码库:

https://gitee.com/gamestorm577/CppStd

成员函数

构造、析构和赋值

构造函数

可以用元素、元素列表、迭代器或者另一个list来构造list。代码示例:

auto print_func = [](const std::list<float>& list)
{for (auto i : list){std::cout << i << " ";}std::cout << std::endl;
};std::vector<float> vec{1.1f, 2.1f, 3.1f};
std::list<float> l1(5, 1.1f);
std::list<float> l2(5);
std::list<float> l3(vec.begin(), vec.end());
std::list<float> l4(l1);
std::list<float> tmp(l1);
std::list<float> l5(std::move(tmp));
std::list<float> l6{11.1f, 12.1, 13.1f};print_func(l1);
print_func(l2);
print_func(l3);
print_func(l4);
print_func(l5);
print_func(l6);

输出结果:

1.1 1.1 1.1 1.1 1.1 
0 0 0 0 0 
1.1 2.1 3.1 
1.1 1.1 1.1 1.1 1.1 
1.1 1.1 1.1 1.1 1.1 
11.1 12.1 13.1 

析构函数

list析构时,会按照正向顺序依次删除元素。代码示例:

struct MyStruct
{MyStruct(int i): Index(i){}~MyStruct(){std::cout << "destruct, Index = " << Index << std::endl;}int Index = 0;
};std::list<MyStruct> l;
l.emplace_front(1);
l.emplace_front(3);
l.emplace_front(5);

输出结果:

destruct, Index = 5
destruct, Index = 3
destruct, Index = 1

赋值函数

可以用元素列表或者另一个list赋值给forward_list。代码示例:

auto print_func = [](const std::list<float>& list)
{for (auto i : list){std::cout << i << " ";}std::cout << std::endl;
};std::list<float> tmp = {1.1f, 2.1f, 3.1f};
std::list<float> l1;
std::list<float> l2;l1 = tmp;
l2 = {2.1f, 2.2f, 2.3f, 2.4f};
print_func(l1);
print_func(l2);

输出结果:

1.1 2.1 3.1 
2.1 2.2 2.3 2.4 

assign

将值赋值给forward_list,可以是元素、元素列表或者迭代器。代码示例:

auto print_func = [](const std::list<float>& list)
{for (auto i : list){std::cout << i << " ";}std::cout << std::endl;
};std::vector<float> vec(10, 1.2f);
std::list<float> l;l.assign(5, 1.2);
print_func(l);
l.assign(vec.begin(), vec.end());
print_func(l);
l.assign({1.1f, 2.1f, 3.1f});
print_func(l);

输出结果:

1.2 1.2 1.2 1.2 1.2 
1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 
1.1 2.1 3.1 

元素访问

front

返回首个元素的引用。示例代码:

std::list<float> l = {1.f, 2.f, 3.f};
l.front() = 4.1f;
std::cout << "l front is: " << l.front() << std::endl;

输出结果:

l front is: 4.1

back

返回最后一个元素的引用。示例代码:

std::list<float> l = {1.f, 2.f, 3.f};
l.back() = 24.1f;
std::cout << "l back is: " << l.back() << std::endl;

输出结果:

l back is: 24.1

迭代器

接口begin、cbegin指向list起始的迭代器,end、cend指向末尾的迭代器。rbegin、crbegin指向起始的逆向迭代器,rend、crend指向末尾的逆向迭代器。代码示例:

std::list<float> l = {1.1f, 2.1f, 3.1f};
for (auto iter = l.rbegin(); iter != l.rend(); ++iter)
{*iter += 27.f;
}for (auto iter = l.crbegin(); iter != l.crend(); ++iter)
{std::cout << "num is: " << *iter << std::endl;
}

输出结果:

num is: 30.1
num is: 29.1
num is: 28.1

容量

empty

检查list是否为空。示例代码:

std::list<float> l1 = {1.1f, 2.1f, 3.1f};
std::list<float> l2;
std::cout << std::boolalpha;
std::cout << "l1 empty: " << l1.empty() << std::endl;
std::cout << "l2 empty: " << l2.empty() << std::endl;

输出结果:

l1 empty: false
l2 empty: true

size

获取list元素的个数。代码示例:

std::list<float> l1 = {1.1f, 2.1f, 3.1f};
std::list<float> l2;
std::cout << "l1 size = " << l1.size() << std::endl;
std::cout << "l2 size = " << l2.size() << std::endl;

输出结果:

l1 size = 3
l2 size = 0

max_size

返回可以容纳的最大元素个数。代码示例:

struct MyStruct
{double num1;double num2;double num3;double num4;
};std::list<float> l1;
std::list<double> l2;
std::list<MyStruct> l3;
std::cout << "l1 max size = " << l1.max_size() << std::endl;
std::cout << "l2 max size = " << l2.max_size() << std::endl;
std::cout << "l3 max size = " << l3.max_size() << std::endl;

输出结果:

l1 max size = 768614336404564650
l2 max size = 768614336404564650
l3 max size = 384307168202282325

修改器

clear

清除所有的元素。代码示例:

std::list<float> l(3, 1.f);
std::cout << std::boolalpha;
std::cout << "l empty: " << l.empty() << std::endl;
l.clear();
std::cout << "l empty: " << l.empty() << std::endl;

输出结果:

l empty: false
l empty: true

insert

在指定的位置插入元素。代码示例:

auto print_func = [](const std::list<float>& list)
{for (auto i : list){std::cout << i << " ";}std::cout << std::endl;
};std::vector<float> vec{40.1f, 40.2f};std::list<float> l = {1.1f, 1.2f, 1.3f};
print_func(l);
l.insert(l.begin(), 15.7f);
print_func(l);
l.insert(std::next(l.begin(), 2), 3, 27.9f);
print_func(l);
l.insert(std::next(l.begin(), 1), vec.begin(), vec.end());
print_func(l);
l.insert(std::next(l.begin(), 1), {70.5f, 75.5f, 71.5f});
print_func(l);

输出结果:

1.1 1.2 1.3 
15.7 1.1 1.2 1.3 
15.7 1.1 27.9 27.9 27.9 1.2 1.3 
15.7 40.1 40.2 1.1 27.9 27.9 27.9 1.2 1.3 
15.7 70.5 75.5 71.5 40.1 40.2 1.1 27.9 27.9 27.9 1.2 1.3 

emplace

在指定位置一个元素。代码示例:

struct MyStruct
{MyStruct(float num1, int num2){std::cout << "construct " << num1 << " " << num2 << std::endl;}
};std::list<MyStruct> f;
f.emplace(f.begin(), 5.5f, 20);

输出结果:

construct 5.5 20

erase

删除指定位置的元素。代码示例:

auto print_func = [](const std::list<float>& list)
{for (auto i : list){std::cout << i << " ";}std::cout << std::endl;
};std::list<float> l = {1.1f, 1.2f, 1.3f, 1.5f, 1.6f, 1.7f, 1.8f};
print_func(l);
l.erase(std::next(l.begin(), 1));
print_func(l);
l.erase(std::next(l.begin(), 1), std::next(l.begin(), 5));
print_func(l);

输出结果:

1.1 1.2 1.3 1.5 1.6 1.7 1.8 
1.1 1.3 1.5 1.6 1.7 1.8 
1.1 1.8 

push_back

将元素添加到末尾。代码示例:

auto print_func = [](const std::list<float>& list)
{for (auto i : list){std::cout << i << " ";}std::cout << std::endl;
};std::list<float> l = {1.1f, 1.2f};
l.push_back(1.3f);
l.push_back(1.4f);
print_func(l);

输出结果:

1.1 1.2 1.3 1.4 

emplace_back

在列表末尾构造一个元素。代码示例:

struct MyStruct
{MyStruct(float num1, int num2){std::cout << "construct " << num1 << " " << num2 << std::endl;}
};std::list<MyStruct> l;
l.emplace_back(1.5f, 17);
l.emplace_back(2.3f, 4);

输出结果:

construct 1.5 17
construct 2.3 4

pop_back

移除末尾的元素。代码示例:

std::list<float> l = {1.1f, 1.2f, 1.3f};
std::cout << "l back is: " << l.back() << std::endl;
l.pop_back();
std::cout << "l back is: " << l.back() << std::endl;

输出结果:

l back is: 1.3
l back is: 1.2

push_front

将元素添加到起始位置。代码示例:

std::list<float> l = {1.1f, 1.2f, 1.3f};
std::cout << "l front is: " << l.front() << std::endl;
l.push_front(17.7f);
std::cout << "l front is: " << l.front() << std::endl;

输出结果:

l front is: 1.1
l front is: 17.7

emplace_front

在列表起始位置构造一个元素。代码示例:

struct MyStruct
{MyStruct(float num1, int num2){std::cout << "construct " << num1 << " " << num2 << std::endl;}
};std::list<MyStruct> l;
l.emplace_front(2.7f, 17);
l.emplace_front(15.1f, 13);

输出结果:

construct 2.7 17
construct 15.1 13

pop_front

移除列表的首个元素。代码示例:

std::list<float> l = {1.1f, 1.2f, 1.3f};
std::cout << "l front is: " << l.front() << std::endl;
l.pop_front();
std::cout << "l front is: " << l.front() << std::endl;

输出结果:

l front is: 1.1
l front is: 1.2

resize

重新设置元素的个数。代码示例:

std::list<float> l = {1.1f, 1.2f, 1.3f};
std::cout << "l size is: " << l.size() << std::endl;
l.resize(2);
std::cout << "l size is: " << l.size() << std::endl;
l.resize(20);
std::cout << "l size is: " << l.size() << std::endl;

输出结果:

l size is: 3
l size is: 2
l size is: 20

swap

交换两个列表的元素内容。代码示例:

std::list<float> l1 = {1.1f, 1.2f, 1.3f};
std::list<float> l2 = {2.1f, 2.2f};
l1.swap(l2);
std::cout << "l1 size = " << l1.size() << std::endl;
std::cout << "l2 size = " << l2.size() << std::endl;

输出结果:

l1 size = 2
l2 size = 3

操作

sort

对元素进行排序。代码示例:

auto print_func = [](const std::list<int>& list)
{for (auto i : list){std::cout << i << " ";}std::cout << std::endl;
};std::list<int> l = {7, 17, 5, 47, 25};
print_func(l);l.sort();
print_func(l);l.sort([](int a, int b){return a > b;});
print_func(l);

输出结果:

7 17 5 47 25 
5 7 17 25 47 
47 25 17 7 5 

merge

合并两个有序的列表。代码示例:

auto print_func = [](const std::list<int>& list)
{for (auto i : list){std::cout << i << " ";}std::cout << std::endl;
};{std::list<int> l1 = {1, 5, 7, 19};std::list<int> l2 = {2, 3, 14, 15};l1.merge(l2);print_func(l1);
}{std::list<int> l1 = {1, 5, 7, 19};std::list<int> l2 = {2, 3, 14, 15};l1.merge(l2,[](int a, int b){return a > b;});print_func(l1);
}

输出结果:

1 2 3 5 7 14 15 19 
2 3 14 15 1 5 7 19 

splice

将另一个列表中的一些元素移动到this列表指定的位置。代码示例:

auto print_func = [](std::string tag, const std::list<float>& list)
{std::cout << tag;for (auto i : list){std::cout << i << " ";}std::cout << std::endl;
};{std::list<float> l1 = {1.5f, 5.5f, 7.5f, 19.5f};std::list<float> l2 = {2.4f, 3.4f, 14.4f, 15.4f};l1.splice(l1.begin(), l2);print_func("l1 = ", l1);print_func("l2 = ", l2);
}{std::list<float> l1 = {1.5f, 5.5f, 7.5f, 19.5f};std::list<float> l2 = {2.4f, 3.4f, 14.4f, 15.4f};l1.splice(std::next(l1.begin(), 2), l2, std::next(l2.begin(), 1));print_func("l1 = ", l1);print_func("l2 = ", l2);
}{std::list<float> l1 = {1.5f, 5.5f, 7.5f, 19.5f};std::list<float> l2 = {2.4f, 3.4f, 14.4f, 15.4f};l1.splice(l1.begin(), l2, l2.begin(), std::next(l2.begin(), 2));print_func("l1 = ", l1);print_func("l2 = ", l2);
}

输出结果:

l1 = 2.4 3.4 14.4 15.4 1.5 5.5 7.5 19.5 
l2 = 
l1 = 1.5 5.5 3.4 7.5 19.5 
l2 = 2.4 14.4 15.4 
l1 = 2.4 3.4 1.5 5.5 7.5 19.5 
l2 = 14.4 15.4 

remove、remove_if

remove移除等于指定值的元素。remove_if移除满足指定要求的元素。代码示例:

auto print_func = [](const std::list<int>& list)
{for (auto i : list){std::cout << i << " ";}std::cout << std::endl;
};std::list<int> l = {5, 9, 17, 27, 15, 5, 5};
print_func(l);l.remove(5);
print_func(l);l.remove_if([](int n){return n > 15;});
print_func(l);

输出结果:

5 9 17 27 15 5 5 
9 17 27 15 
9 15 

reverse

反转元素的顺序。代码示例:

auto print_func = [](const std::list<float>& list)
{for (auto i : list){std::cout << i << " ";}std::cout << std::endl;
};std::list<float> l = {1.1f, 3.1f, 19.1f, 7.1f};
print_func(l);
l.reverse();
print_func(l);

输出结果:

1.1 3.1 19.1 7.1 
7.1 19.1 3.1 1.1 

unique

删除连续的重复元素。代码示例:

auto print_func = [](const std::list<int>& list)
{for (auto i : list){std::cout << i << " ";}std::cout << std::endl;
};std::list<int> l = {1, 3, 3, 17, 7, 3, 17, 17, 19, 1, 3, 1};
print_func(l);
l.unique();
print_func(l);

输出结果:

1 3 3 17 7 3 17 17 19 1 3 1 
1 3 17 7 3 17 19 1 3 1 

非成员函数

比较运算符

operator==,!=,<,<=,>,>=用于比较两个forward_list。代码示例:

std::list<int> l1 = {1, 2, 3, 4};
std::list<int> l2 = {1, 5};
std::cout << std::boolalpha;
std::cout << "l1 == l2: " << (l1 == l2) << std::endl;
std::cout << "l1 != l2: " << (l1 != l2) << std::endl;
std::cout << "l1 <  l2: " << (l1 < l2) << std::endl;
std::cout << "l1 <= l2: " << (l1 <= l2) << std::endl;
std::cout << "l1 >  l2: " << (l1 > l2) << std::endl;
std::cout << "l1 >= l2: " << (l1 >= l2) << std::endl;

输出结果:

l1 == l2: false
l1 != l2: true
l1 <  l2: true
l1 <= l2: true
l1 >  l2: false
l1 >= l2: false

swap

交换两个列表的元素内容。示例代码:

std::list<float> l1 = {1.5f, 2.5f};
std::list<float> l2 = {17.1f, 15.1f, 27.1f};
std::swap(l1, l2);
std::cout << "l1 front is: " << l1.front() << std::endl;
std::cout << "l2 front is: " << l2.front() << std::endl;

输出结果:

l1 front is: 17.1
l2 front is: 1.5

erase、erase_if

erase删除等于指定值的元素,erase_if删除满足条件的元素。代码示例:

auto print_func = [](const std::list<int>& list)
{for (auto i : list){std::cout << i << " ";}std::cout << std::endl;
};std::list<int> l = {5, 7, 17, 29, 7, 7, 35};
print_func(l);std::erase(l, 7);
print_func(l);std::erase_if(l,[](int a){return a > 17;});
print_func(l);

输出结果:

5 7 17 29 7 7 35 
5 17 29 35 
5 17 

相关文章:

容器库(5)-std::list

std::forward_list是可以从任何位置快速插入和移除元素的容器&#xff0c;不支持快速随机访问&#xff0c;支持正向和反向的迭代。 本文章的代码库&#xff1a; https://gitee.com/gamestorm577/CppStd 成员函数 构造、析构和赋值 构造函数 可以用元素、元素列表、迭代器…...

配置VMware实现从服务器到虚拟机的一键启动脚本

正文共&#xff1a;1666 字 15 图&#xff0c;预估阅读时间&#xff1a;2 分钟 首先祝大家新年快乐&#xff01;略备薄礼&#xff0c;18000个红包封面来讨个开年好彩头&#xff01; 虽然之前将服务器放到了公网&#xff08;成本增加了100块&#xff0c;内网服务器上公网解决方案…...

第5讲小程序微信用户登录实现

小程序微信用户登录实现 小程序登录和jwt&#xff0c;httpclient工具类详细介绍可以看下小锋老师的 小程序电商系统课程&#xff1a;https://www.bilibili.com/video/BV1kP4y1F7tU application.yml加上小程序登录需要的参数&#xff0c;小伙伴们可以登录小程序后台管理&#…...

Kong 负载均衡

负载均衡是一种将API请求流量分发到多个上游服务的方法。负载均衡可以提高整个系统的响应速度&#xff0c;通过防止单个资源过载而减少故障。 在以下示例中&#xff0c;您将使用部署在两台不同服务器或上游目标上的应用程序。Kong网关需要在这两台服务器之间进行负载均衡&…...

基于Chrome插件的Chatgpt对话无损导出markdown格式(Typora完美显示)

Google插件名称为&#xff1a;ChatGPT to MarkDown plus, 下载地址为ChatGPT to MarkDown plus使用方法&#xff1a;见GitHub主页或插件介绍页面https://github.com/thisisbaiy/ChatGPT-To-Markdown-google-plugin/tree/main 我将源代码上传至了GitHub&#xff0c;欢迎star, Is…...

react函数组件中使用context

效果 1.在父组件中创建一个createcontext并将他导出 import React, { createContext } from react import Bpp from ./Bpp import Cpp from ./Cpp export let MyContext createContext(我是组件B) export let Ccontext createContext(我是组件C)export default function App…...

【MATLAB源码-第137期】基于matlab的NOMA系统和OFDMA系统对比仿真。

操作环境&#xff1a; MATLAB 2022a 1、算法描述 NOMA&#xff08;非正交多址&#xff09;和OFDMA&#xff08;正交频分多址&#xff09;是两种流行的无线通信技术&#xff0c;广泛应用于现代移动通信系统中&#xff0c;如4G、5G和未来的6G网络。它们的设计目标是提高频谱效…...

【FPGA Verilog】各种加法器Verilog

1bit半加器adder设计实例 module adder(cout,sum,a,b); output cout; output sum; input a,b; wire cout,sum; assign {cout,sum}ab; endmodule 解释说明 &#xff08;1&#xff09;assign {cout,sum}ab 是连续性赋值 对于线网wire进行赋值&#xff0c;必须以assign或者dea…...

【MySQL】-21 MySQL综合-7(MySQL主键+MySQL外检约束+MySQL唯一约束+MySQL检查约束)

MySQL主键MySQL外检约束MySQL唯一约束MySQL检查约束 MySQL主键选取设置主键约束的字段在创建表时设置主键约束在创建表时设置复合主键在修改表时添加主键约束 MySQL外键约束选取设置 MySQL 外键约束的字段在创建表时设置外键约束在修改表时添加外键约束删除外键约束 MySQL唯一约…...

【大厂AI课学习笔记】【1.6 人工智能基础知识】(3)神经网络

深度学习是机器学习中一种基于对数据进行表征学习的算法。观测值(例如一幅草莓照片)可以使用 多种方式来表示&#xff0c;如每个像素强度值的向量&#xff0c;或者更抽象地表示成一系列边、特定形状的区域等。 深度学习的最主要特征是使用神经网络作为计算模型。神经网络模型 …...

指针的基本含义及其用法

1.前言 在学习C语言的时候&#xff0c;我们会经常接触一个概念&#xff0c;指针和地址&#xff0c;关于这两个概念很多人并不能理解地十分透彻&#xff0c;接下来我将详细介绍一下这两者的概念 2.地址 我们知道计算机的上CPU&#xff08;中央处理器&#xff09;在处理数据的时…...

黄金交易策略(Nerve Nnife.mql4):趋势做单

完整EA&#xff1a;Nerve Knife.ex4黄金交易策略_黄金趋势ea-CSDN博客 当大小趋势相同行情走向也相同&#xff0c;就会开仓做顺势单&#xff0c;并会顺势追单&#xff0c;以达到快速止盈平仓的效果。大趋势追求稳定&#xff0c;小趋势追求敏捷&#xff0c;行情走向比小趋势更敏…...

HiveSQL——条件判断语句嵌套windows子句的应用

注&#xff1a;参考文章&#xff1a; SQL条件判断语句嵌套window子句的应用【易错点】--HiveSql面试题25_sql剁成嵌套判断-CSDN博客文章浏览阅读920次&#xff0c;点赞4次&#xff0c;收藏4次。0 需求分析需求&#xff1a;表如下user_idgood_namegoods_typerk1hadoop1011hive1…...

ClickHouse--01--简介

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 1. ClickHouse 简介官网&#xff1a; [https://clickhouse.com/docs/zh](https://clickhouse.com/docs/zh) 1.1 大数据处理场景1.2 什么是 ClickHouse1.3 OLAP 场景…...

【Django-ninja】在django ninja中处理异常

1. 直接抛内置异常 Django ninja内置了一些常用异常类。 from ninja.errors import HttpErrorapi.get("/some/resource") def some_operation(request):if True:raise HttpError(503, "Service Unavailable. Please retry later.")2. 覆写异常类 可以覆…...

【并发编程】原子累加器

&#x1f4dd;个人主页&#xff1a;五敷有你 &#x1f525;系列专栏&#xff1a;并发编程 ⛺️稳重求进&#xff0c;晒太阳 JDK8之后有专门做累加的类&#xff0c;效率比自己做快数倍以上 累加器性能比较 参数是方法 // supplier 提供者 无中生有 ()->结果// func…...

Java 基于微信小程序的电子商城购物系统

博主介绍&#xff1a;✌程序员徐师兄、7年大厂程序员经历。全网粉丝12W、csdn博客专家、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ &#x1f345;文末获取源码联系&#x1f345; &#x1f447;&#x1f3fb; 精彩专栏推荐订阅&#x1f447;…...

Git Push -f 命令详解

直接看原文: Git Push -f 命令详解 - 玩转Linux - SegmentFault 思否 -------------------------------------------------------------------------------------------------------------------------------- git push -f 这个命令的作用是将自己本地仓库的代码直接推送至仓…...

【LeetCode每日一题】前缀和的例题1248. 统计「优美子数组」974. 和可被 K 整除的子数组

leetcode 724. 寻找数组的中心索引 题目描述 给定一个整数类型的数组 nums&#xff0c;请编写一个能够返回数组 “中心索引” 的方法。 我们是这样定义数组 中心索引 的&#xff1a;数组中心索引的左侧所有元素相加的和等于右侧所有元素相加的和。 如果数组不存在中心索引&…...

备战蓝桥杯---数学基础3

本专题主要围绕同余来讲&#xff1a; 下面介绍一下基本概念与定理&#xff1a; 下面给出解这方程的一个例子&#xff1a; 下面是用代码实现扩展欧几里得算法&#xff1a; #include<bits/stdc.h> using namespace std; int gcd(int a,int b,int &x,int &y){if(b…...

【ROS】Nav2源码之nav2_behavior_tree-行为树节点列表

1、行为树节点分类 在 Nav2(Navigation2)的行为树框架中,行为树节点插件按照功能分为 Action(动作节点)、Condition(条件节点)、Control(控制节点) 和 Decorator(装饰节点) 四类。 1.1 动作节点 Action 执行具体的机器人操作或任务,直接与硬件、传感器或外部系统…...

css的定位(position)详解:相对定位 绝对定位 固定定位

在 CSS 中&#xff0c;元素的定位通过 position 属性控制&#xff0c;共有 5 种定位模式&#xff1a;static&#xff08;静态定位&#xff09;、relative&#xff08;相对定位&#xff09;、absolute&#xff08;绝对定位&#xff09;、fixed&#xff08;固定定位&#xff09;和…...

C++ 求圆面积的程序(Program to find area of a circle)

给定半径r&#xff0c;求圆的面积。圆的面积应精确到小数点后5位。 例子&#xff1a; 输入&#xff1a;r 5 输出&#xff1a;78.53982 解释&#xff1a;由于面积 PI * r * r 3.14159265358979323846 * 5 * 5 78.53982&#xff0c;因为我们只保留小数点后 5 位数字。 输…...

Redis数据倾斜问题解决

Redis 数据倾斜问题解析与解决方案 什么是 Redis 数据倾斜 Redis 数据倾斜指的是在 Redis 集群中&#xff0c;部分节点存储的数据量或访问量远高于其他节点&#xff0c;导致这些节点负载过高&#xff0c;影响整体性能。 数据倾斜的主要表现 部分节点内存使用率远高于其他节…...

初学 pytest 记录

安装 pip install pytest用例可以是函数也可以是类中的方法 def test_func():print()class TestAdd: # def __init__(self): 在 pytest 中不可以使用__init__方法 # self.cc 12345 pytest.mark.api def test_str(self):res add(1, 2)assert res 12def test_int(self):r…...

微软PowerBI考试 PL300-在 Power BI 中清理、转换和加载数据

微软PowerBI考试 PL300-在 Power BI 中清理、转换和加载数据 Power Query 具有大量专门帮助您清理和准备数据以供分析的功能。 您将了解如何简化复杂模型、更改数据类型、重命名对象和透视数据。 您还将了解如何分析列&#xff0c;以便知晓哪些列包含有价值的数据&#xff0c;…...

LINUX 69 FTP 客服管理系统 man 5 /etc/vsftpd/vsftpd.conf

FTP 客服管理系统 实现kefu123登录&#xff0c;不允许匿名访问&#xff0c;kefu只能访问/data/kefu目录&#xff0c;不能查看其他目录 创建账号密码 useradd kefu echo 123|passwd -stdin kefu [rootcode caozx26420]# echo 123|passwd --stdin kefu 更改用户 kefu 的密码…...

C/C++ 中附加包含目录、附加库目录与附加依赖项详解

在 C/C 编程的编译和链接过程中&#xff0c;附加包含目录、附加库目录和附加依赖项是三个至关重要的设置&#xff0c;它们相互配合&#xff0c;确保程序能够正确引用外部资源并顺利构建。虽然在学习过程中&#xff0c;这些概念容易让人混淆&#xff0c;但深入理解它们的作用和联…...

Rust 开发环境搭建

环境搭建 1、开发工具RustRover 或者vs code 2、Cygwin64 安装 https://cygwin.com/install.html 在工具终端执行&#xff1a; rustup toolchain install stable-x86_64-pc-windows-gnu rustup default stable-x86_64-pc-windows-gnu ​ 2、Hello World fn main() { println…...

上位机开发过程中的设计模式体会(1):工厂方法模式、单例模式和生成器模式

简介 在我的 QT/C 开发工作中&#xff0c;合理运用设计模式极大地提高了代码的可维护性和可扩展性。本文将分享我在实际项目中应用的三种创造型模式&#xff1a;工厂方法模式、单例模式和生成器模式。 1. 工厂模式 (Factory Pattern) 应用场景 在我的 QT 项目中曾经有一个需…...