博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
set容器
阅读量:4559 次
发布时间:2019-06-08

本文共 1144 字,大约阅读时间需要 3 分钟。

简介:先进先出

1.1 是关联式容器,自身是有规则,会进行排序,默认排序升序

1.2 数据结构是二叉树,迭代器是双向

1.3 set容器键值不允许相同

1.4 查找速度很快,有排序需求和查找速度需求,用set容器来存储数据

void test01(){    queue
q; q.push(10); q.push(20); q.push(30); q.push(40); q.push(50); cout << q.front() << endl; cout << q.back() << endl; cout << endl; while (!q.empty()) { cout << q.front() << endl; q.pop(); } cout << "size:" << q.size() << endl;}//2.存储对象class Maker{public: Maker(string name, int age) { this->name = name; this->age = age; }public: string name; int age;};void test02(){ queue
q; q.push(Maker("aaa1", 10)); q.push(Maker("aaa2", 20)); q.push(Maker("aaa3", 30)); cout << q.front().name<<" "<
<< endl; cout << q.back().name<<" " <
<< endl; cout << endl; while (!q.empty()) { cout << q.front().name << " " << q.front().age << endl; q.pop(); } cout << "size:" << q.size() << endl;}int main(){ test02(); system("pause"); return EXIT_SUCCESS;}

 

转载于:https://www.cnblogs.com/kony9527/p/10655844.html

你可能感兴趣的文章
angularJS通过post方法下载excel文件
查看>>
也谈阻塞、非阻塞、同步、异步
查看>>
SQL Server分布式事务问题
查看>>
第二个日记
查看>>
使用PLSQL导入导出数据库
查看>>
Codeforces Round #321 (Div. 2)
查看>>
Android SDK Manager 更新代理配置
查看>>
kafka版本0.8.2.0-Producer Configs之request.required.acks
查看>>
一个强悍的极简单递归小例子帮你从程序执行的角度理解递归
查看>>
2016012026+小学四则运算练习软件项目报告
查看>>
Android - 读取网站json并显示到Activity
查看>>
idea Live Template 快速使用
查看>>
git 初级
查看>>
[hdu4347]The Closest M Points(平衡树式kdtree)
查看>>
[hdu2874]Connections between cities(LCA+并查集)
查看>>
web端功能测试总结(二)
查看>>
Thymeleaf-模板引擎
查看>>
去重算法
查看>>
POJ 3298 Antimonotonicity (思维)
查看>>
c#获取硬件信息
查看>>