当前位置:网站首页>STL deque
STL deque
2022-07-23 10:37:00 【joker_0030】
#include<iostream>
#include<deque>
using namespace std;
int main()
{
//定义对象
deque<int> db;
//赋值
db.push_back(12);
//迭代器
deque<int>::iterator ite = db.begin();
//输出
for (ite; ite != db.end(); ite++)
{
cout << *ite;
}
system("pause");
return 0;
}
*vector:
1、 连续空间
2、随机位置插入/删除效率低。
3、随机访问速率高(下标运算),a[3]。
4、不支持头添加,支持尾添加。
5、随机访问操作频率高,选vector。
*list
1、不连续空间。
2、随机位置插入/删除效率高。
3、不支持随机访问。
4、支持头添加、支持尾添加。
5、插入删除频率高,头添加,选list。
*deque:
1、段连续空间。空间不够就另外申请定量空间,链接在原空间的尾巴上。
2、随机插入删除效率不高,但优于vector低于list。
3、支持随机访问(比vector慢,因为要进行堆跳转),迭代器结构复杂,减低访问速率。
4、支持头添加,尾添加。
5、随机访问+头添加,选择deque。a、支持随机访问,即支持[ ] 以及at(),性能没有vector好。b、可以在内部进行插入和删除操作,但性能不及 list。
6、对比vector:a、没有capacity和reserve。b、多了push_back,pop_back。c、其他函数一样。
边栏推荐
- ESP三相SVPWM控制器的simulink仿真
- 信号量
- VMware虚拟机下载安装使用教程
- 【7.16】代码源 -【数组划分】【拆拆】【选数2】【最大公约数】
- Byte stream & character stream of IO stream
- Postgresql快照优化Globalvis新体系分析(性能大幅增强)
- RSA加密的使用
- Smart headline: smart clothing forum will be held on August 4, and the whole house smart sales will exceed 10billion in 2022
- 安全合理用电 收获清凉一“夏”
- Dynamic planning - force buckle
猜你喜欢

How to realize 485 wireless communication between multiple sensors and Siemens PLC?

基于matlab的BOC调制信号捕获仿真

The pit trodden by real people tells you to avoid the 10 mistakes often made in automated testing

idea一次启动多个项目

Leetcode: 17. letter combination of phone number

MySQL的大心脏 — 索引

Leetcode-227-basic calculator||

报错 | cannot read property ‘_normalized‘ of undefined

深入理解CAS (自旋锁)

安全合理用电 收获清凉一“夏”
随机推荐
Monotonous stack!!!
易基因|靶基因DNA甲基化测序(Target-BS)
leetcode: 17. 电话号码的字母组合
Start process of activity
Simulation of synchronization performance of BOC modulation and demodulation based on MATLAB, output tracking curve and identification curve under different lead lag code distance
581. Shortest unordered continuous subarray
Uniapp realizes horizontal click and slide menu
安全作业7.22
[machine learning basics] unsupervised learning (5) -- generation model
Byte stream & character stream of IO stream
智头条:智装论坛将于8月4日举行,2022全屋智能销售将破100亿
IO流之 字节流 & 字符流
[CTFHub]JWT 的头部和有效载荷这两部分的数据是以明文形式传输的,如果其中包含了敏感信息的话,就会发生敏感信息泄露。试着找出FLAG。格式为 flag{}
pytorch opencv pil图像预处理比较
[ctfhub] the data of JWT header and payload are transmitted in clear text. If sensitive information is contained in it, sensitive information will be leaked. Try to find the flag. Format is flag{}
[untitled] test [untitled] test
头部姿态估计原理及可视化_loveliuzz的博客-程序员宅基地_头部姿态估计
Kettle實現共享數據庫連接及插入更新組件實例
Blazor快速实现扫雷(MineSweeper)
Feignclient utilise un tutoriel détaillé (illustration)