Container 总结

来源:互联网 发布:linux退出系统命令 编辑:程序博客网 时间:2024/05/16 21:05

 vector在末端插入,适合随机访问,原理数组,适合开始就知道对象数目的情况

deque在首尾插入,

list在末端插入,适合随机插入删除。

set适合排除重复

list排队要用成员sort,不要用general sort,general sort对list效率比较低

 

deque is usually more efficient than list for pushing things at the front.

The queue is a restricted form of a deque.

priority_queue is an adapter which is built on top of one of the basic
sequences – the default is vector.

make_heap就是把转换范围内的所有数按照堆的要求进行重排;而push_heap是把一个数添加到排列好的堆中。

 

vector<bool> is a specialization of the vector template. A normal bool variable requires at
least one byte, but since a bool only has two states the ideal implementation of vector<bool>
is such that each bool value only requires one bit. This means the iterator must be speciallydefined,
and cannot be a bool*.

原创粉丝点击