当前位置:网站首页>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。
边栏推荐
- What is the experience of writing concurrent tool classes (semaphore, cyclicbarrier, countdownlatch) by yourself in line 30?
- MySQL sub database and sub table and its smooth expansion scheme
- C file operation details
- Cannot resolve symbol 'override' of idea clone‘
- CMT registration - Google Scholar ID, semantic scholar ID, and DBLP ID
- A series of problems of dp+ backtracking segmentation palindrome string
- Mobile keyboard (day 73)
- 移动通信的新定义:R&SCMX500 将提高5G设备的IP数据吞吐量
- Svn: e00002: can't convert string from 'UTF-8' to native encoding problem solving
- Realize the communication before two pages (using localstorage)
猜你喜欢

错误代码0x80004005

轮播图van-swipe的报错:cannot read a properties of null(reading width)

Data Lake: introduction to Apache Hudi

Interviewer: if the order is not paid within 30 minutes after it is generated, it will be automatically cancelled. How to realize it?

Expressions régulières \ \ B \ \ b compréhension de l'appariement des limites des mots

IO stream sorting

openEuler 资源利用率提升之道 01:概论

C file operation details

The simple use of ADB command combined with monkey is super detailed

Talk about the application of FIFO
随机推荐
关于Aries框架增删改查-查Demo
You must know the ten vulnerabilities of invalid access control
Okaleido tiger NFT is about to log in to the binance NFT platform. Are you looking forward to it?
Mobile keyboard (day 73)
C user defined type details
Hcip day 9 notes (OSPF routing feedback, routing policy, and Configuration Guide)
[C language] file operation
WPS前骨干历时10年打造新型软件,Excel用户:我为此改用WPS
The new idea 2022.2 was officially released, and the new features are nice
数据湖:开源数据湖方案DeltaLake、Hudi、Iceberg对比分析
Insist on accompanying study
JS 數組 isAarray() typeof
Hospital PACS source code PACS ultrasonic Department source code DICOM image workstation source code [source code free sharing]
Basic syntax of MySQL DDL and DML and DQL
Xiaodi and Xiaohui
FTP服务与配置
Basic knowledge of trigger (Part 2)
Programmers may still be programmers, and coders may only be coders
Basic use of Pinia
移动通信的新定义:R&SCMX500 将提高5G设备的IP数据吞吐量