Main Page Modules Namespaces C++ Classes Compound List File List Index
TNL: TNL::Vector< T > Class Template Reference

# TNL::Vector< T > Class Template Reference

`#include <tnlVector.h>`

## Detailed Description

### template<class T>
class TNL::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.

## VectorSTL STL interface

typedef T | value_type
typedef T & | reference
typedef const T & | const_reference
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)
S32 | size () const
bool | empty () const
T & | front ()
const T & | front () const
T & | back ()
const T & | back () const
void | push_front (const T &)
void | push_back (const T &)
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)

## Public Member Functions

| Vector (const U32 initialSize=0)
| Vector (const Vector &)
| ~Vector ()
VectorExtended Extended Interface
U32 | memSize () const
T * | address () const
U32 | setSize (U32)
void | insert (U32)
void | erase (U32)
void | erase_fast (U32)
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)

## Protected Member Functions

void | checkSize (U32 newElementCount)
| checks the element count against the array size and resizes the array if necessary
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 T TNL::Vector< T >::value_type

template<class T>

typedef T& TNL::Vector< T >::reference

template<class T>

typedef const T& TNL::Vector< T >::const_reference

template<class T>

typedef S32 TNL::Vector< T >::difference_type

template<class T>

typedef U32 TNL::Vector< T >::size_type

template<class T>

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

## Constructor & Destructor Documentation

template<class T>

TNL::Vector< T >::Vector | ( | const U32 | initialSize = `0` | ) | `[inline]`

template<class T>

TNL::Vector< T >::Vector | ( | const Vector< T > & |  | ) | `[inline]`

template<class T>

TNL::Vector< T >::~Vector | ( |  | ) | `[inline]`

## Member Function Documentation

template<class T>

void TNL::Vector< T >::checkSize | ( | U32 | newElementCount | ) | `[inline, protected]`

checks the element count against the array size and resizes the array if necessary

template<class T>

void TNL::Vector< T >::destroy | ( | U32 | start,
|  | U32 | end |
| ) |  |  | `[inline, protected]`

Destructs elements from start to end-1.

template<class T>

void TNL::Vector< T >::construct | ( | U32 | start,
|  | U32 | end |
| ) |  |  | `[inline, protected]`

Constructs elements from start to end-1.

template<class T>

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

template<class T>

Vector< T > & TNL::Vector< T >::operator= | ( | const Vector< T > & | p | ) | `[inline]`

template<class T>

S32 TNL::Vector< T >::size | ( |  | ) | const`[inline]`

template<class T>

bool TNL::Vector< T >::empty | ( |  | ) | const`[inline]`

template<class T>

T & TNL::Vector< T >::front | ( |  | ) | `[inline]`

template<class T>

const T & TNL::Vector< T >::front | ( |  | ) | const`[inline]`

template<class T>

T & TNL::Vector< T >::back | ( |  | ) | `[inline]`

template<class T>

const T & TNL::Vector< T >::back | ( |  | ) | const`[inline]`

template<class T>

void TNL::Vector< T >::push_front | ( | const T & |  | ) | `[inline]`

template<class T>

void TNL::Vector< T >::push_back | ( | const T & |  | ) | `[inline]`

template<class T>

void TNL::Vector< T >::pop_front | ( |  | ) | `[inline]`

template<class T>

void TNL::Vector< T >::pop_back | ( |  | ) | `[inline]`

template<class T>

T & TNL::Vector< T >::operator[] | ( | U32 |  | ) | `[inline]`

template<class T>

const T & TNL::Vector< T >::operator[] | ( | U32 |  | ) | const`[inline]`

template<class T>

T& TNL::Vector< T >::operator[] | ( | S32 | i | ) | `[inline]`

template<class T>

const T& TNL::Vector< T >::operator[] | ( | S32 | i | ) | const`[inline]`

template<class T>

void TNL::Vector< T >::reserve | ( | U32 |  | ) | `[inline]`

template<class T>

U32 TNL::Vector< T >::memSize | ( |  | ) | const

template<class T>

T * TNL::Vector< T >::address | ( |  | ) | const`[inline]`

template<class T>

U32 TNL::Vector< T >::setSize | ( | U32 |  | ) | `[inline]`

template<class T>

void TNL::Vector< T >::insert | ( | U32 |  | ) | `[inline]`

template<class T>

void TNL::Vector< T >::erase | ( | U32 |  | ) | `[inline]`

template<class T>

void TNL::Vector< T >::erase_fast | ( | U32 |  | ) | `[inline]`

template<class T>

void TNL::Vector< T >::clear | ( |  | ) | `[inline]`

template<class T>

void TNL::Vector< T >::compact | ( |  | ) |

template<class T>

void TNL::Vector< T >::sort | ( | compare_func | f | ) | `[inline]`

template<class T>

T & TNL::Vector< T >::first | ( |  | ) | `[inline]`

template<class T>

T & TNL::Vector< T >::last | ( |  | ) | `[inline]`

template<class T>

const T & TNL::Vector< T >::first | ( |  | ) | const`[inline]`

template<class T>

const T & TNL::Vector< T >::last | ( |  | ) | const`[inline]`

template<class T>

void TNL::Vector< T >::set | ( | void * | addr,
|  | U32 | sz |
| ) |  |  |

## Field Documentation

template<class T>

U32 TNL::Vector< T >::mElementCount`[protected]`

Number of elements currently in the Vector.

template<class T>

U32 TNL::Vector< T >::mArraySize`[protected]`

Number of elements allocated for the Vector.

template<class T>

T* TNL::Vector< T >::mArray`[protected]`

Pointer to the Vector elements.