一般不会写分配器,默认使用默认分配器
序列式容器 关联式容器 无序容器
**Array:**初始空间设多大就是多大,而不是根据元素的多少来分配空间。(前闭后闭)
**Vector:**根据插入多少元素来分配空间。(前闭后开)
**Deque:**前后都可以插入元素。(前开后开)
**List:**双向环状链表。(两个指针)
**Forward-list:**单向链表。(一个指针)
**Set/Multiset:**高度平衡二叉树,key和value无分别。
Map/Multimap:和Set的唯一区别就是,key和value区分开,可通过key来找元素,而Map不能有重复的元素,Multimap可以有重复的元素,Set也同理。
**Hash Table:**由不同篮子组成,每个篮子代表不同的链表。
clock():程序从运行开始到调用该函数的时间
size():真正的元素个数
capacity():容量
**slist:**单向链表
sort在类里
list的迭代器是连续的,而sort算法只有无需迭代器
sort在类外
泛化:传入的是任意的type
偏特化:传入的是任意type的指针
allocate调用operator new,然后operator new调用malloc
deallocate调用operator delete,然后operator delete调用free
额外开销:cookie(夹心饼干),红色,上下两块,各占4个字节,总共八个字节
除了array和vector,其他容器的iterator都要是类,因为需要智能指针
array不可扩充
本质:vector
扩充后,将旧容器的元素copy到新容器的中段
根据key排序
优先使用容器自身提供的算法,因为是特化的,更适合该容器
55%53=2,2%53=2,于是这两个元素都放到2号位,串联起来
只是名字换了而已
先用某个函数判断出迭代器种类,然后根据迭代器种类调用相对应的算法,提高了算法的效率
并非强制,只是暗示
小括号产生临时对象
条件:继承去回答问题
函数对象:仿函数临时创造的对象
适配器:把东西记起来,以便后面使用
t.head()->第一个元素
t.tail()->第一个后面的所有元素
t.tail().head()->第二个元素