STL deque的介绍(1)
2014-09-01 10:00
218 查看
原文地址:http://www.cplusplus.com/reference/deque/deque/
class template
<deque>
Double ended queue
deque (usually pronounced like "deck") is an irregular acronym of double-ended queue. Double-ended queues are sequence containers with dynamic sizes
that can be expanded or contracted on both ends (either its front or its back).
双端队列(很像“列车”)是一种不规则的有两个结尾的队列缩写。两边结尾的队列容器可以从两边动态增长或者缩小。(从它的头部或者尾部)。
Specific libraries may implement deques in different ways, generally as some form of dynamic array. But in any case, they allow for the individual elements to be accessed directly through random access iterators, with storage handled automatically
by expanding and contracting the container as needed.
不同的库可能用不同的方法实现deques,一般都是由动态数组构成,但在任何情况下,他们允许使用随即访问迭代器直接访问其中的任何元素,使用内存操纵其动态增长以及缩小。
Therefore, they provide a functionality similar to vectors, but with efficient insertion and deletion
of elements also at the beginning of the sequence, and not only at its end. But, unlike vectors, deques are
not guaranteed to store all its elements in contiguous storage locations: accessing elements in a
因此,他们提供类似vector的功能,但是提供了更高效的在序列头部插入以及删除元素的方法,在其尾部也是一样,但是不同与vector,deques不保证将所有的元素连续地存放那个在内存的位置,使用deque的指针偏移访问另一个元素将会导致为定义的行为。
Both vectors and deques provide a very similar interface and can be used for similar purposes, but
internally both work in quite different ways: While vectors use a single array that needs to be occasionally reallocated for growth, the elements of a deque can be scattered in different chunks of storage, with the container keeping the necessary information
internally to provide direct access to any of its elements in constant time and with a uniform sequential interface (through iterators). Therefore, deques are a little more complex internally than vectors,
but this allows them to grow more efficiently under certain circumstances, especially with very long sequences, where reallocations become more expensive.
vector和deque都提供了相似的接口用于相似的功能。但是在内部是以不同的方式实现的。当vector像普通数组一样使用时需要偶尔重分配以实现增长,deque却可以在不同的块上分散存放元素,容器依旧保持必须的信息以提供在常量时间内对其元素的直接访问,因此,deques内部比vector要复杂一些,但是他依旧允许在确定的环境下高效增长,特别是在长的序列中,重分配操作会变得消耗很昂贵!
For operations that involve frequent insertion or removals of elements at positions other than the beginning or the end, deques perform worse and have less consistent iterators and references than lists and forward
lists.
如果需要在begin和end之外的位置频繁地插入或者移除元素,deque的表现比list以及forward list要差很多。
SequenceElements in sequence containers are ordered in a strict linear sequence. Individual elements are accessed by their position in this sequence.Dynamic arrayGenerally implemented as a dynamic array, it allows direct access to any element in the sequence and provides relatively fast addition/removal of elements at the beginning or the end of the sequence.Allocator-awareThe container uses an allocator object to dynamically handle its storage needs.
TType of the elements.
Aliased as member type deque::value_type.
AllocType of the allocator object used to define the storage allocation model. By default, the allocator class
template is used, which defines the simplest memory allocation model and is value-independent.
Aliased as member type deque::allocator_type.
C++98
C++11
(constructor)
Construct deque container (public member function )(destructor)
Deque destructor (public member function )operator=
Assign content (public member function )
Iterators:
begin
Return iterator to beginning (public member function )end
Return iterator to end (public member function )rbegin
Return reverse iterator to reverse beginning (public member function )rend
Return reverse iterator to reverse end (public member function )cbegin
Return const_iterator to beginning (public member function )cend
Return const_iterator to end (public member function )crbegin
Return const_reverse_iterator to reverse beginning (public member function )crend
Return const_reverse_iterator to reverse end (public member function )
Capacity:
size
Return size (public member function )max_size
Return maximum size (public member function )resize
Change size (public member function )empty
Test whether container is empty (public member function )shrink_to_fit
Shrink to fit (public member function )
Element access:
operator[]
Access element (public member function )at
Access element (public member function )front
Access first element (public member function )back
Access last element (public member function )
Modifiers:
assign
Assign container content (public member function )push_back
Add element at the end (public member function )push_front
Insert element at beginning (public member function )pop_back
Delete last element (public member function )pop_front
Delete first element (public member function )insert
Insert elements (public member function )erase
Erase elements (public member function )swap
Swap content (public member function )clear
Clear content (public member function )emplace
Construct and insert element (public member function )emplace_front
Construct and insert element at beginning (public member function )emplace_back
Construct and insert element at the end (public member function )
Allocator:
get_allocator
Get allocator (public member function )
relational operators
Relational operators for deque (function )swap
Exchanges the contents of two deque containers (function template )
——————————————————————————————————————————————————————————————————
//翻译的不好的地方请多多指导,可以在下面留言或者点击左上方邮件地址给我发邮件,指出我的错误以及不足,以便我修改,更好的分享给大家,谢谢。
转载请注明出处:http://blog.csdn.net/qq844352155
author:天下无双
Email:coderguang@gmail.com
2014-9-1
于GDUT
——————————————————————————————————————————————————————————————————
class template
<deque>
std::deque
template < class T, class Alloc = allocator<T> > class deque;
Double ended queue
deque (usually pronounced like "deck") is an irregular acronym of double-ended queue. Double-ended queues are sequence containers with dynamic sizes
that can be expanded or contracted on both ends (either its front or its back).
双端队列(很像“列车”)是一种不规则的有两个结尾的队列缩写。两边结尾的队列容器可以从两边动态增长或者缩小。(从它的头部或者尾部)。
Specific libraries may implement deques in different ways, generally as some form of dynamic array. But in any case, they allow for the individual elements to be accessed directly through random access iterators, with storage handled automatically
by expanding and contracting the container as needed.
不同的库可能用不同的方法实现deques,一般都是由动态数组构成,但在任何情况下,他们允许使用随即访问迭代器直接访问其中的任何元素,使用内存操纵其动态增长以及缩小。
Therefore, they provide a functionality similar to vectors, but with efficient insertion and deletion
of elements also at the beginning of the sequence, and not only at its end. But, unlike vectors, deques are
not guaranteed to store all its elements in contiguous storage locations: accessing elements in a
dequeby offsetting a pointer to another element causes undefined behavior.
因此,他们提供类似vector的功能,但是提供了更高效的在序列头部插入以及删除元素的方法,在其尾部也是一样,但是不同与vector,deques不保证将所有的元素连续地存放那个在内存的位置,使用deque的指针偏移访问另一个元素将会导致为定义的行为。
Both vectors and deques provide a very similar interface and can be used for similar purposes, but
internally both work in quite different ways: While vectors use a single array that needs to be occasionally reallocated for growth, the elements of a deque can be scattered in different chunks of storage, with the container keeping the necessary information
internally to provide direct access to any of its elements in constant time and with a uniform sequential interface (through iterators). Therefore, deques are a little more complex internally than vectors,
but this allows them to grow more efficiently under certain circumstances, especially with very long sequences, where reallocations become more expensive.
vector和deque都提供了相似的接口用于相似的功能。但是在内部是以不同的方式实现的。当vector像普通数组一样使用时需要偶尔重分配以实现增长,deque却可以在不同的块上分散存放元素,容器依旧保持必须的信息以提供在常量时间内对其元素的直接访问,因此,deques内部比vector要复杂一些,但是他依旧允许在确定的环境下高效增长,特别是在长的序列中,重分配操作会变得消耗很昂贵!
For operations that involve frequent insertion or removals of elements at positions other than the beginning or the end, deques perform worse and have less consistent iterators and references than lists and forward
lists.
如果需要在begin和end之外的位置频繁地插入或者移除元素,deque的表现比list以及forward list要差很多。
Container properties
SequenceElements in sequence containers are ordered in a strict linear sequence. Individual elements are accessed by their position in this sequence.Dynamic arrayGenerally implemented as a dynamic array, it allows direct access to any element in the sequence and provides relatively fast addition/removal of elements at the beginning or the end of the sequence.Allocator-awareThe container uses an allocator object to dynamically handle its storage needs.
Template parameters
TType of the elements.Aliased as member type deque::value_type.
AllocType of the allocator object used to define the storage allocation model. By default, the allocator class
template is used, which defines the simplest memory allocation model and is value-independent.
Aliased as member type deque::allocator_type.
Member types
C++98C++11
member type | definition | notes |
---|---|---|
value_type | The first template parameter (T) | |
allocator_type | The second template parameter (Alloc) | defaults to: allocator<value_type> |
reference | allocator_type::reference | for the default allocator: value_type& |
const_reference | allocator_type::const_reference | for the default allocator: const value_type& |
pointer | allocator_type::pointer | for the default allocator: value_type* |
const_pointer | allocator_type::const_pointer | for the default allocator: const value_type* |
iterator | a random access iterator to value_type | convertible to const_iterator |
const_iterator | a random access iterator to const value_type | |
reverse_iterator | reverse_iterator<iterator> | |
const_reverse_iterator | reverse_iterator<const_iterator> | |
difference_type | a signed integral type, identical to: iterator_traits<iterator>::difference_type | usually the same as ptrdiff_t |
size_type | an unsigned integral type that can represent any non-negative value ofdifference_type | usually the same as size_t |
Member functions
(constructor)Construct deque container (public member function )(destructor)
Deque destructor (public member function )operator=
Assign content (public member function )
Iterators:
begin
Return iterator to beginning (public member function )end
Return iterator to end (public member function )rbegin
Return reverse iterator to reverse beginning (public member function )rend
Return reverse iterator to reverse end (public member function )cbegin
Return const_iterator to beginning (public member function )cend
Return const_iterator to end (public member function )crbegin
Return const_reverse_iterator to reverse beginning (public member function )crend
Return const_reverse_iterator to reverse end (public member function )
Capacity:
size
Return size (public member function )max_size
Return maximum size (public member function )resize
Change size (public member function )empty
Test whether container is empty (public member function )shrink_to_fit
Shrink to fit (public member function )
Element access:
operator[]
Access element (public member function )at
Access element (public member function )front
Access first element (public member function )back
Access last element (public member function )
Modifiers:
assign
Assign container content (public member function )push_back
Add element at the end (public member function )push_front
Insert element at beginning (public member function )pop_back
Delete last element (public member function )pop_front
Delete first element (public member function )insert
Insert elements (public member function )erase
Erase elements (public member function )swap
Swap content (public member function )clear
Clear content (public member function )emplace
Construct and insert element (public member function )emplace_front
Construct and insert element at beginning (public member function )emplace_back
Construct and insert element at the end (public member function )
Allocator:
get_allocator
Get allocator (public member function )
Non-member functions overloads
relational operatorsRelational operators for deque (function )swap
Exchanges the contents of two deque containers (function template )
——————————————————————————————————————————————————————————————————
//翻译的不好的地方请多多指导,可以在下面留言或者点击左上方邮件地址给我发邮件,指出我的错误以及不足,以便我修改,更好的分享给大家,谢谢。
转载请注明出处:http://blog.csdn.net/qq844352155
author:天下无双
Email:coderguang@gmail.com
2014-9-1
于GDUT
——————————————————————————————————————————————————————————————————
相关文章推荐
- C++ STL deque介绍与使用方法
- 全面讲解介绍各种交换机的分类(3)
- 精通Silverlight——11.1.4 Silverlight程序集介绍
- KDB+ database 介绍
- WebServices SOAP简单介绍
- final 用法介绍:
- Nutch 1.3 学习笔记 10-1 - Ntuch 插件机制简单介绍
- 接口测试从零开始系列4_junit断言介绍
- aplModule实现原理介绍
- Minifilter微过滤框架:框架介绍以及驱动层和应用层的通讯
- Web常用函数介绍(LoadRunner相关)
- 适配器模式(Adapter Pattern)(一):适配器模式介绍
- 详细介绍PHP的目录操作和文件操作
- Linux CC与GCC的区别概括介绍
- 光流法的介绍(含C++代码)
- 用 Java 生成 Java - CodeModel 介绍
- css3动画-00通俗易懂的介绍,你不能错过
- Android 5.0 Lollipop中新的Activity过渡效果介绍
- C#开发COM组件供其他开发环境或工具调用介绍(转)