vector是怎么实现的??
我在编程代码中见到类似这样的定义:typedef std::vector<XQQuery*, XQillaAllocator<XQQuery*> > ImportedModules;查找其定义找到一个vector文件
template<class _Ty,
class _Ax>
class vector
: public _Vector_val<_Ty, _Ax>
{ // varying size array of values
public:
typedef vector<_Ty, _Ax> _Myt;
typedef _Vector_val<_Ty, _Ax> _Mybase;
typedef typename _Mybase::_Alty _Alloc;
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type _Dift;
typedef _Dift difference_type;
typedef typename _Alloc::pointer _Tptr;
typedef typename _Alloc::const_pointer _Ctptr;
typedef _Tptr pointer;
typedef _Ctptr const_pointer;
typedef typename _Alloc::reference _Reft;
typedef _Reft reference;
typedef typename _Alloc::const_reference const_reference;
typedef typename _Alloc::value_type value_type;
#define _VEC_ITER_BASE(it) (it)._Myptr
这只是一部分代码,我想问的是,此时的vector和STL中的vector一样吗?STL中vector一般都是形如vector<int>或vector< vector<int> >,这里的vector是怎么回事??是不是也可以有vector<int,int>,STL中的容器自己也可以起同样的名字对其重新定义吗?上面vector的形式在后面的代码中也用到了iterator迭代器,若是自己重新定义一个vector也可以用iterator来遍历?
template<class _Ty,
class _Ax>
class vector
: public _Vector_val<_Ty, _Ax>
{ // varying size array of values
public:
typedef vector<_Ty, _Ax> _Myt;
typedef _Vector_val<_Ty, _Ax> _Mybase;
typedef typename _Mybase::_Alty _Alloc;
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type _Dift;
typedef _Dift difference_type;
typedef typename _Alloc::pointer _Tptr;
typedef typename _Alloc::const_pointer _Ctptr;
typedef _Tptr pointer;
typedef _Ctptr const_pointer;
typedef typename _Alloc::reference _Reft;
typedef _Reft reference;
typedef typename _Alloc::const_reference const_reference;
typedef typename _Alloc::value_type value_type;
#define _VEC_ITER_BASE(it) (it)._Myptr
这只是一部分代码,我想问的是,此时的vector和STL中的vector一样吗?STL中vector一般都是形如vector<int>或vector< vector<int> >,这里的vector是怎么回事??是不是也可以有vector<int,int>,STL中的容器自己也可以起同样的名字对其重新定义吗?上面vector的形式在后面的代码中也用到了iterator迭代器,若是自己重新定义一个vector也可以用iterator来遍历?
...全文
相关推荐
vector的c语言实现
vector的c语言实现,支持各种数据类型,相当于使用C语言实现了模板功能
C++ Vector 动态数组的实现
主要介绍了C++ Vector 动态数组的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
《STL系列》之vector原理及实现
《STL系列》之vector原理及实现
vector实现矩阵运算
vector< vector > m(a, vector(b)); 这个语句中,标准vector创建了一个包含a个向量的向量, 其中每个向量中包含有b个整数。这a * b个元素中都保存 着默认值0。 用这种方式可以轻松地返回一个数组或矩阵。
C++ vector操作实现
主要介绍了C++ vector操作实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧


