Name

Vector — Portable, light-weight and fast version of a vector.

Synopsis

template<typename T> 
class Vector:
  // types
  typedef size_t    size_type;     
  typedef T *       iterator;      
  typedef const T * const_iterator;

  # construct/copy/destruct
  __init__()
  __init__(size_type)
  __init__(size_type, const T &)
  __init__(const Vector< T > &)
  Vector& operator=(const Vector< T > &)
  __del__()

  # public member functions

  None resize(size_type) 
  None assign(size_type, const T &) 
  iterator push_back(const T &) 
  None pop_back() 
  iterator insert(const_iterator, size_type, const T &) 
  iterator insert(const_iterator, const_iterator, const_iterator) 
  iterator insert(const_iterator, const T &) 
  None swap(Vector< T > &) 
  None 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
  None reserve(size_type) 
  iterator erase(const_iterator, const_iterator) 
  None erase(size_type) 
  Vector< T > & operator+=(const Vector< T > &) 
  T * release() 

  # private member functions

  None append(size_type) 
  None reserve1(size_type) 

Description

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 construct/copy/destruct

  1. __init__()

    default constructor


  2. __init__(size_type n)

    reserve place for n objects


  3. __init__(size_type n, const T & t)

    create n identical copies of the object in a vector


  4. __init__(const Vector< T > & v)

    copy constructor


  5. Vector& operator=(const Vector< T > & )

    assignment operator


  6. __del__()


Vector public member functions

  1. None resize(size_type n)

    adjust vector size to n


  2. None assign(size_type n, const T & )

    initialize vector with n objects of type T


  3. iterator push_back(const T & t)

    add object T to the tail of the vector


  4. None pop_back()

    remove object from the tail of the vector


  5. iterator insert(const_iterator p, size_type n, const T & t)

    insert n objects T before p


  6. iterator insert(const_iterator p, const_iterator q1, const_iterator q2)

    insert objects q1...q2 before p


  7. iterator insert(const_iterator p, const T & t)

    insert single object T before p


  8. None swap(Vector< T > & )

    swap contents of the vector with another vector


  9. None clear()

    clear vector


  10. size_type size() const

    returns size of the vector


  11. T & operator[](size_type i)


  12. const T & operator[](size_type i) const


  13. iterator begin()

    returns begin of the vector


  14. const_iterator begin() const


  15. iterator end()

    returns pointer right beyond the last element of the vector


  16. const_iterator end() const


  17. T & back()

    returns reference to the last element of the vector


  18. const T & back() const


  19. None reserve(size_type n)

    reserve memory for at least n objects


  20. iterator erase(const_iterator q1, const_iterator q2)

    erase objects q1...q2


  21. None erase(size_type idx)

    erase object with index idx


  22. Vector< T > & operator+=(const Vector< T > & v1)

    append vector v1 to the current vector


  23. T * release()

    Give up ownership of the data; reset the vector.


Vector private member functions

  1. None append(size_type )


  2. None reserve1(size_type )