Vector< T > Class Template Reference

#include <tVector.h>

Inheritance diagram for Vector< T >:

Inheritance graph
[legend]
List of all members.

Detailed Description


template<class T> class Vector< T >

A dynamic array template class.

The vector grows as you insert or append elements. Insertion is fastest at the end of the array. Resizing of the array can be avoided by pre-allocating space using the reserve() method.


STL interface

typedef T value_type
typedef T & reference
typedef const T & const_reference
typedef T * iterator
typedef const T * const_iterator
typedef S32 difference_type
typedef U32 size_type
typedef difference_type(QSORT_CALLBACK *) compare_func (T *a, T *b)
Vector< T > & operator= (const Vector< T > &p)
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
S32 size () const
bool empty () const
void insert (iterator, const T &)
void erase (iterator)
T & front ()
const T & front () const
T & back ()
const T & back () const
void push_front (const T &)
void push_back (const T &)
U32 push_front_unique (const T &)
U32 push_back_unique (const T &)
S32 find_next (const T &, U32 start=0)
void pop_front ()
void pop_back ()
T & operator[] (U32)
const T & operator[] (U32) const
T & operator[] (S32 i)
const T & operator[] (S32 i) const
void reserve (U32)
U32 capacity () const

Extended interface

U32 memSize () const
T * address () const
U32 setSize (U32)
void increment ()
void decrement ()
void increment (U32)
void decrement (U32)
void insert (U32)
void erase (U32)
void erase_fast (U32)
void erase_fast (iterator)
void clear ()
void compact ()
void sort (compare_func f)
T & first ()
T & last ()
const T & first () const
const T & last () const
void set (void *addr, U32 sz)
void merge (const Vector &p)

Public Member Functions

 Vector (const U32 initialSize=0)
 Vector (const U32 initialSize, const char *fileName, const U32 lineNum)
 Vector (const char *fileName, const U32 lineNum)
 Vector (const Vector &)
 ~Vector ()

Protected Member Functions

bool resize (U32)
void destroy (U32 start, U32 end)
 Destructs elements from start to end-1.
void construct (U32 start, U32 end)
 Constructs elements from start to end-1.
void construct (U32 start, U32 end, const T *array)

Protected Attributes

U32 mElementCount
 Number of elements currently in the Vector.
U32 mArraySize
 Number of elements allocated for the Vector.
T * mArray
 Pointer to the Vector elements.


Member Typedef Documentation

template<class T>
typedef difference_type(QSORT_CALLBACK *) Vector< T >::compare_func(T *a, T *b)


Constructor & Destructor Documentation

template<class T>
Vector< T >::Vector ( const U32  initialSize = 0  )  [inline]

template<class T>
Vector< T >::Vector ( const U32  initialSize,
const char *  fileName,
const U32  lineNum 
) [inline]

template<class T>
Vector< T >::Vector ( const char *  fileName,
const U32  lineNum 
) [inline]

template<class T>
Vector< T >::Vector ( const Vector< T > &   )  [inline]

template<class T>
Vector< T >::~Vector (  )  [inline]


Member Function Documentation

template<class T>
bool Vector< T >::resize ( U32   )  [inline, protected]

template<class T>
void Vector< T >::destroy ( U32  start,
U32  end 
) [inline, protected]

Destructs elements from start to end-1.

template<class T>
void Vector< T >::construct ( U32  start,
U32  end 
) [inline, protected]

Constructs elements from start to end-1.

template<class T>
void Vector< T >::construct ( U32  start,
U32  end,
const T *  array 
) [inline, protected]

template<class T>
Vector< T > & Vector< T >::operator= ( const Vector< T > &  p  )  [inline]

template<class T>
S32 Vector< T >::size (  )  const [inline]

template<class T>
bool Vector< T >::empty (  )  const [inline]

template<class T>
void Vector< T >::insert ( iterator  ,
const T &   
) [inline]

template<class T>
void Vector< T >::erase ( iterator   )  [inline]

template<class T>
void Vector< T >::push_front ( const T &   )  [inline]

template<class T>
void Vector< T >::push_back ( const T &   )  [inline]

template<class T>
U32 Vector< T >::push_front_unique ( const T &   )  [inline]

template<class T>
U32 Vector< T >::push_back_unique ( const T &   )  [inline]

template<class T>
S32 Vector< T >::find_next ( const T &  ,
U32  start = 0 
) [inline]

template<class T>
void Vector< T >::pop_front (  )  [inline]

template<class T>
void Vector< T >::pop_back (  )  [inline]

template<class T>
T& Vector< T >::operator[] ( S32  i  )  [inline]

template<class T>
const T& Vector< T >::operator[] ( S32  i  )  const [inline]

template<class T>
void Vector< T >::reserve ( U32   )  [inline]

template<class T>
U32 Vector< T >::capacity (  )  const [inline]

template<class T>
U32 Vector< T >::memSize (  )  const [inline]

template<class T>
T * Vector< T >::address (  )  const [inline]

template<class T>
U32 Vector< T >::setSize ( U32   )  [inline]

template<class T>
void Vector< T >::increment (  )  [inline]

template<class T>
void Vector< T >::decrement (  )  [inline]

template<class T>
void Vector< T >::increment ( U32   )  [inline]

template<class T>
void Vector< T >::decrement ( U32   )  [inline]

template<class T>
void Vector< T >::insert ( U32   )  [inline]

template<class T>
void Vector< T >::erase ( U32   )  [inline]

template<class T>
void Vector< T >::erase_fast ( iterator   )  [inline]

template<class T>
void Vector< T >::clear (  )  [inline]

template<class T>
void Vector< T >::compact (  )  [inline]

template<class T>
void Vector< T >::sort ( compare_func  f  )  [inline]

template<class T>
void Vector< T >::set ( void addr,
U32  sz 
) [inline]

template<class T>
void Vector< T >::merge ( const Vector< T > &  p  )  [inline]


Member Data Documentation

template<class T>
U32 Vector< T >::mElementCount [protected]

Number of elements currently in the Vector.

template<class T>
U32 Vector< T >::mArraySize [protected]

Number of elements allocated for the Vector.

template<class T>
T* Vector< T >::mArray [protected]

Pointer to the Vector elements.