关于deque的一些细节

在查看deque时发现这段话,特此保存。


The choice of container type should be based in general on the type of searching and inserting required by the application. 

通常应当根据应用要求的查找和插入形式来选择容器类型。

Vectors should be the preferred container for managing a sequence when random access to any element is at a premium and insertions or deletions of elements are only required at the end of a sequence. 

vector容器管理顺序元素,并且对这些元素有大量的随机访问,插入与删除只会在序列末尾进行。

The performance of the list container is superior when efficient insertions and deletions (in constant time) at any location within the sequence is at a premium. 

list容器对于顺序容器需要花大量时间的任意位置插入和删除的操作非常有效率(常数时间)。

Such operations in the middle of the sequence require element copies and assignments proportional to the number of elements in the sequence (linear time).

这样的操作对于顺序队列中间的元素来说,需要的拷贝和赋值操作正比与顺序队列的长度(线性时间)。


一下是关于迭代器与插入删除操作的关系,多线程编程有用。

Deque reallocation occurs when a member function must insert or erase elements of the sequence:

  • If an element is inserted into an empty sequence, or if an element is erased to leave an empty sequence, then iterators earlier returned by begin and end become invalid.

  • If an element is inserted at the first position of the deque, then all iterators, but no references, that designate existing elements become invalid.

  • If an element is inserted at the end of the deque, then end and all iterators, but no references, that designate existing elements become invalid.

  • If an element is erased at the front of the deque, only that iterator and references to the erased element become invalid.

  • If the last element is erased from the end of the deque, only that iterator to the final element and references to the erased element become invalid.

Otherwise, inserting or erasing an element invalidates all iterators and references.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值