本文在我另外一個部落格也同步: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>