std::deque
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <deque>
|
||
| template< class T, |
||
std::deque(双端队列)是一个索引序列的容器,允许快速的插入和删除的开始和结束。此外,在任一端插入和删除一个deque从未无效指针或引用的其余元素.Original:
std::deque (double-ended queue) is an indexed sequence container that allows fast insertion and deletion at both the beginning and the end. In addition, insertion and deletion at either end of a deque never invalidates pointers or references to the rest of the elements.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
反对std::vector,一个deque的元素连续存储:典型的实现使用一个单独分配固定大小的数组的顺序.
Original:
As opposed to std::vector, the elements of a deque are not stored contiguously: typical implementations use a sequence of individually allocated fixed-size arrays.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
的双端队列的存储根据需要自动地膨胀和收缩。扩展一个deque比扩张的std::vector便宜,因为它不涉及的现有元素复制到新的内存位置.
Original:
The storage of the deque is automatically expanded and contracted as needed. Expansion of a deque is cheaper than the expansion of a std::vector because it does not involve copying of the existing elements to a new memory location.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
双端队列上常见的操作的复杂性(效率)是如下:
Original:
The complexity (efficiency) of common operations on deques is as follows:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- 随机访问 - 常数O(1)Original:Random access - constant O(1)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - 在结尾或开头插入或移除元素 - 摊销不变O(1)Original:Insertion or removal of elements at the end or beginning - amortized constant O(1)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - 插入或移除元素 - 线性O(n)Original:Insertion or removal of elements - linear O(n)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::deque符合要求的Container,AllocatorAwareContainer,SequenceContainer和ReversibleContainer.Original:
std::deque meets the requirements of Container, AllocatorAwareContainer, SequenceContainer and ReversibleContainer.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 会员类型
| 会员类型
Original: Member type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
value_type
|
T
|
allocator_type
|
Allocator
|
size_type
|
无符号整数类型(通常是size_t)
Original: Unsigned integral type (usually size_t) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
difference_type
|
Signed integer type (usually ptrdiff_t) |
reference
|
Allocator::reference (至 C++11)value_type& (C++11 起)
|
const_reference
|
Allocator::const_reference (至 C++11)const value_type& (C++11 起)
|
pointer
|
Allocator::pointer (至 C++11)std::allocator_traits<Allocator>::pointer (C++11 起) |
const_pointer
|
Allocator::const_pointer (至 C++11) std::allocator_traits<Allocator>::const_pointer (C++11 起) |
iterator
|
RandomAccessIterator
|
const_iterator
|
常量随机访问迭代器 |
reverse_iterator
|
std::reverse_iterator<iterator> |
const_reverse_iterator
|
std::reverse_iterator<const_iterator> |
[编辑] 成员函数
| 构建 deque Original: constructs the deque The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
destructs the deque (公共成员函数) | |
| 将值分配到容器中 Original: assigns values to the container The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 将值分配到容器中 Original: assigns values to the container The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 返回的关联分配器 Original: returns the associated allocator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
Original: Element access The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| 访问指定的元素与边界检查 Original: access specified element with bounds checking The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 访问指定的元素 Original: access specified element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 访问的第一个元素 Original: access the first element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| access the last element (公共成员函数) | |
Original: Iterators The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| 返回一个迭代的开始 Original: returns an iterator to the beginning The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 返回一个迭代的结束 Original: returns an iterator to the end The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 返回一个反向迭代的开始 Original: returns a reverse iterator to the beginning The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 返回一个反向迭代结束 Original: returns a reverse iterator to the end The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
Original: Capacity The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| 检查是否容器是空的 Original: checks whether the container is empty The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 返回的元素数 Original: returns the number of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 返回可能的最大数量的元素 Original: returns the maximum possible number of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| (C++11) |
通过释放未使用的内存减少了内存的使用情况 Original: reduces memory usage by freeing unused memory The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) |
Original: Modifiers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| 清除其内容 Original: clears the contents The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 插入元素 Original: inserts elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| (C++11) |
constructs element in-place (公共成员函数) |
| 擦除元素 Original: erases elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 将元素添加到年底 Original: adds elements to the end The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| (C++11) |
构造就地中的元素,在末端 Original: constructs elements in-place at the end The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) |
| 删除最后一个元素 Original: removes the last element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 插入元素的开始 Original: inserts elements to the beginning The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| (C++11) |
构造元素的地方开始 Original: constructs elements in-place at the beginning The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) |
| 删除第一个元素 Original: removes the first element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| changes the number of elements stored (公共成员函数) | |
| 交换的内容 Original: swaps the contents The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
[编辑] 非成员函数
| 字典中的值比较的deque Original: lexicographically compares the values in the deque The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数模板) | |
| 专业的std::swap算法 Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数模板) | |