Vector — Portable, light-weight and fast version of a vector.
template<typename T> class Vector { public: // types typedef size_t size_type; typedef T * iterator; typedef const T * const_iterator; // construct/copy/destruct Vector(); Vector(size_type); Vector(size_type, const T &); Vector(const Vector< T > &); Vector& operator=(const Vector< T > &); ~Vector(); // public member functions void resize(size_type) ; void assign(size_type, const T &) ; iterator push_back(const T &) ; void pop_back() ; iterator insert(const_iterator, size_type, const T &) ; iterator insert(const_iterator, const_iterator, const_iterator) ; iterator insert(const_iterator, const T &) ; void swap(Vector< T > &) ; void clear() ; size_type size() const; T & operator[](size_type) ; const T & operator[](size_type) const; iterator begin() ; const_iterator begin() const; iterator end() ; const_iterator end() const; T & back() ; const T & back() const; void reserve(size_type) ; iterator erase(const_iterator, const_iterator) ; void erase(size_type) ; Vector< T > & operator+=(const Vector< T > &) ; T * release() ; // private member functions void append(size_type) ; void reserve1(size_type) ; };
This vector has one important difference from the STL one: this vector does not use copy constructors for moving objects around; it uses memmove() instead. So, objects which keep pointers to themselves may not behave correctly in this Vector.
Vector
public member functionsadjust vector size to n
initialize vector with n objects of type T
add object T to the tail of the vector
remove object from the tail of the vector
insert n objects T before p
insert objects q1...q2 before p
insert single object T before p
swap contents of the vector with another vector
clear vector
returns size of the vector
returns begin of the vector
returns pointer right beyond the last element of the vector
returns reference to the last element of the vector
reserve memory for at least n objects
erase objects q1...q2
erase object with index idx
Vector< T > & operator+=(const Vector< T > & v1) ;
append vector v1 to the current vector
Give up ownership of the data; reset the vector.