vector

来源:互联网 发布:java调用api接口 例子 编辑:程序博客网 时间:2024/09/21 09:02

Vector 是一种顺序性的容器,按照严格线性存储各种对象。他其实就是一种动态的数组。

Vector 可以方便的做一下:

  • 可以通过下标直接访问元素 (常量时间constant amortized  time).    
  • 用任何顺序迭代元素(linear time).
  • 在尾部添加删除元素 (constant amortized  time). 
在C++ Standard Template Library 中,vector有两个参数:

template < class T, class  Allocator = allocator<T> > class vector;

这两个参数的意义:

  • T: 元素的类型
  • Allocator: 元素所要分配的空间大小。

 


0 0
原创粉丝点击