当前位置:网站首页>STL set容器
STL set容器
2022-07-24 03:23:00 【joker_0030】
#include <set>
#include <string>
#include<iostream>
using namespace std;
int main()
{
set<string> db;
db.insert(string("abs"));
db.insert(string("abd"));
db.insert(string("abe"));
db.insert(string("abc"));
db.insert(string("aba"));
//删除。
db.erase(string("abe"));
//db.erase("abe");
//迭代器输出
set<string>::iterator ite = db.begin();
for ( ite; ite !=db.end(); ite++)
{
cout << *ite<<endl;
}
system("pause");
return 0;
}
set:
1、关键字保存:通过实际值来排序,通过实际值来查找;
特点:a、高效访问,对比map:
1、数据结构是红黑树;
2、map是分键值对,set键值即实际值,实际值即键值。
b、键值不能重复。
2、红黑树(平衡 排序二叉树):x=log2^N:
a、N是数据总量。
b、x是查找次数,2^x>=N。
3、键值不能改,实际值可以改。但是一般修改实际值就是修改键值会使整个结构会发生改变,一般不提倡修改。
4、没有容量;得到元素的个数,size(),尺寸;得到一个元素是否存在,或者判断一个元素是否存在, count(const key&_key);判断是否是空empty(),空返回1,非空返回0;迭代器,可以循环、也可以自加++,但不可以+2。
边栏推荐
- JIRA automation experience sharing for 2 years
- Tweenmax+svg Pikachu transformation ball
- 数据湖:Apache Hudi简介
- An introductory example of structure and combinatorial ideas in go language
- Error code 0x80004005
- Android开发——Kotlin语法之Lambda表达式
- Test interview questions
- Basic syntax of MySQL DDL and DML and DQL
- [wepy2.0] installation
- C自定义类型详解
猜你喜欢

CMT 注册——Google Scholar Id,Semantic Scholar Id,和 DBLP Id

Web3 traffic aggregation platform starfish OS gives players a new paradigm experience of metauniverse

A series of problems of dp+ backtracking segmentation palindrome string

实现两个页面之前的通信(使用localStorage)

322. Change

CMT registration - Google Scholar ID, semantic scholar ID, and DBLP ID

IO流分类整理

What is IMU?

JS small game running bear and cat source code

Jump statements break and continue
随机推荐
IDEA Clone的项目报Cannot resolve symbol ‘Override‘
Data Lake: introduction to Apache Hudi
Advantages, disadvantages and summary of sequence list and linked list
在openEuler社区开源的Embedded SIG,来聊聊它的多 OS 混合部署框架
LCD1602 - binge 51
Gpushare.com | 如何使用TensorBoardX可视化工具?
Some properties of differential array operation
Rules for generating 13 digit barcode EAN-13 Code: the thirteenth digit is the verification code obtained by calculating the first twelve digits.
Read and understand the advantages of the LAAS scheme of elephant swap
轮播图van-swipe的报错:cannot read a properties of null(reading width)
SkyWalking分布式系统应用程序性能监控工具-上
A series of problems of dp+ backtracking segmentation palindrome string
Express built-in Middleware
Basic syntax of MySQL DDL and DML and DQL
Outlook client outlook.com mailbox setting method
Leetcode Hot 100 (Brush Topic 8) (232 / 88 / 451 / offer10 / offer22 / 344 /)
Binary tree traversal (day 74)
B. Eastern Exhibition- Codeforces Round #703 (Div. 2)
MySQL learning - MySQL software installation and environment configuration (Windows) details!
[wepy2.0] installation