Chapter 8.顺序容器deque
来源:互联网 发布:淘宝开服装店怎么进货 编辑:程序博客网 时间:2024/05/16 14:51
deque简介
deque被实现为双端队列,由多个连续内存块构成,deque是list和vector的兼容,分为多个块,每一个块大小是512字节,块通过map块管理,map块里保存每个块得首地址。因此该容器也有索引操作operator[ ],效率没vector高。,同样的也可以通过[]、at()来随机访问元素,所以在实现上面deque不保证在内存中以严格的连续地址存放,所以实现上面比vector要复杂的多
deque的优点
1.可以通过[]/at()来实现随机访问元素
2.可以通过迭代器以多种顺序来遍历各元素
3.可以高效的通过push_front()/pop_front/push_back()/pop_back()在其队头或队尾添加或移除元素
Capacity:
emptyTest whether deque is emptysizeReturn sizemax_sizeReturn maximum size [test winxp 32bit vs2008 value is: 1073741823]resizeChange size
Element access:
operator[]Access elementatAccess elementfrontAccess first elementbackAccess last element
Modifiers:
assignAssign list contentpush_backAdd element at the endpop_backDelete last elementinsertInsert elementseraseErase elementsswapSwap content//algorithm exists swap, and the same behavior.clearClear contentpush_frontInsert element at beginning→list and deque uniquepop_frontDelete first element→list and deque unique
Allocator:
get_allocator
eg: deque<int> mydeque; int * p; unsigned int i; // allocate an array of 5 elements using deque's allocator: p=mydeque.get_allocator().allocate(5); // assign some values to array for (i=0; i<5; i++) p[i]=i; cout << "The allocated array contains:"; for (i=0; i<5; i++) cout << " " << p[i]; cout << endl; mydeque.get_allocator().deallocate(p,5);Output:
The allocated array contains: 0 1 2 3 4
- Chapter 8.顺序容器deque
- chapter 9 顺序容器
- Chapter 4:序列式容器之 deque
- C++容器--- 顺序性容器<deque>
- Chapter 6.顺序容器vector
- Chapter 7.顺序容器list
- 由浅入深-顺序容器(vector deque list)
- C++顺序容器vector、deque、list
- 顺序容器vector、list、deque的区别
- 顺序容器list、vector、deque的优劣
- 顺序容器vector、list、deque的区别
- 顺序容器vector、list、deque(整理中)
- STL顺序容器【vector】【deque】【list】
- STL顺序容器-deque(双向队列)
- C++ 顺序容器 STL deque 类
- 顺序容器vector、list、deque的区别
- C++ 9.1 顺序容器-----vector、list、deque
- C++顺序容器vector、deque、list
- 【hdoj2098】分拆素数和
- 2440init.s中的大小端(问题尚未解决,解决中...)
- 吴垠大哥的配置文件
- Linux 小技巧
- 关于javascript 回调函数中变量作用域的讨论
- Chapter 8.顺序容器deque
- 揭秘传智播客网页平面就业的真实工资!!
- Linux主机建立信任关系
- iOS上简单推送通知(Push Notification)的实现
- 《Unix环境高级编程》:线程清理处理程序
- eclipse快捷键
- Android应用全屏的方法
- Spring Batch 2.1.8 中文文档(六)
- 2002年日语四级能力考试答案