本文在我另外一个博客也同步:http://www.cnblogs.com/pengjunwei/p/4414677.html Vector表示可以改变大小的数组容器。 就像数组,其元素的向量使用连续的存储位置,这意味着还可以访问其元素上使用偏移量经常指向元素的指针,和在数组中一样有效。但与数组不同,其大小可动态变化,他们的存储容器自动处理。 在vector内部,使用动态分配的数组向量来存储他们的内容。此数组可能需要重新分配,以便规模的扩大新元素被插入时,这意味着为它分配一个新的数组,并将所有元素。这是一种相对较昂贵的任务在处理时间方面,因此,向量不重新分配每个时间元素添加到容器。 Vector,Deque,List 三个容器同属序列容器,操作统一。
类型如下:
member type | definition | notes |
---|---|---|
value_type | The first template parameter (T) | |
allocator_type | The second template parameter (Alloc) | defaults to:allocator<value_type> |
reference | value_type& | |
const_reference | const value_type& | |
pointer | allocator_traits<allocator_type>::pointer | for the default allocator:value_type* |
const_pointer | allocator_traits<allocator_type>::const_pointer | for the default allocator:const value_type* |
iterator | a random access iterator to value_type | convertible toconst_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 of difference_type | usually the same as size_t |
Vector操作接口如下: (部分来自其他实现)

上诉接口的实现: <script src=" https://code.csdn.net/snippets/640698.js"></script>