#include <tvector.h>
Public Types | |
typedef T * | iterator |
Iterator. | |
typedef const T * | const_iterator |
Constant iterator. | |
Public Member Functions | |
tvector () | |
Create an empty array. | |
tvector (unsigned n) | |
Create an array with n elements. | |
tvector (unsigned n, const T &value) | |
Create an array with n initialized elements. | |
tvector (const tvector &a) | |
Copy constructor. | |
unsigned | size () const |
Gets the number of elements. | |
unsigned | capacity () const |
Gets the capacity. | |
operator T * () | |
Gets the underlying array. | |
operator const T * () const | |
Gets the underlying array. | |
tvector & | operator= (const tvector &a) |
Copy. | |
void | clear () |
Remove all elements and delete the underlying array. | |
void | erase (iterator first) |
Erase an element. | |
void | erase (iterator first, iterator last) |
Erase elements. | |
void | erase (const T &x) |
Erase elements with the specified value. | |
void | resize (unsigned n) |
Resize array and initialize the new elements. | |
void | resize (unsigned n, const T &value) |
Resize array and initialize the new elements. | |
void | insert (iterator p, const T &value) |
Insert a new element. | |
void | insert (iterator p, const T *first, const T *last) |
Insert new elements. | |
void | push_back (const T &value) |
Add a new element. | |
void | pop_back () |
Remove the last element. | |
T & | operator[] (int k) |
Gets the kth element. | |
T & | front () |
Gets the kth element. | |
const T & | front () const |
Gets the first element as a constant. | |
T & | back () |
Gets the last element. | |
const T & | back () const |
Gets the last element as a constant. | |
iterator | begin () |
Returns an iterator to the beginning. | |
const_iterator | begin () const |
Returns an iterator to the beginning. | |
iterator | end () |
Returns an iterator to end. | |
const_iterator | end () const |
Returns an iterator to end. | |
void | sort () |
quicksort the contend of the vector, T must define operator < |
Extra method: erase(T);
typedef const T* tvector< T >::const_iterator |
Constant iterator.
Create an array with n initialized elements.
unsigned tvector< T >::size | ( | ) | const [inline] |
Gets the number of elements.
unsigned tvector< T >::capacity | ( | ) | const [inline] |
Gets the capacity.
tvector< T >::operator T * | ( | ) | [inline] |
Gets the underlying array.
tvector< T >::operator const T * | ( | ) | const [inline] |
Gets the underlying array.
void tvector< T >::clear | ( | ) | [inline] |
Remove all elements and delete the underlying array.
Erase elements.
void tvector< T >::erase | ( | const T & | x | ) | [inline] |
Erase elements with the specified value.
void tvector< T >::resize | ( | unsigned | n | ) | [inline] |
Resize array and initialize the new elements.
void tvector< T >::resize | ( | unsigned | n, | |
const T & | value | |||
) | [inline] |
Resize array and initialize the new elements.
Insert a new element.
void tvector< T >::insert | ( | iterator | p, | |
const T * | first, | |||
const T * | last | |||
) | [inline] |
Insert new elements.
void tvector< T >::push_back | ( | const T & | value | ) | [inline] |
Add a new element.
void tvector< T >::pop_back | ( | ) | [inline] |
Remove the last element.
T& tvector< T >::operator[] | ( | int | k | ) | [inline] |
Gets the kth element.
T& tvector< T >::front | ( | ) | [inline] |
Gets the kth element.
Gets the first element.
const T& tvector< T >::front | ( | ) | const [inline] |
Gets the first element as a constant.
T& tvector< T >::back | ( | ) | [inline] |
Gets the last element.
const T& tvector< T >::back | ( | ) | const [inline] |
Gets the last element as a constant.
const_iterator tvector< T >::begin | ( | ) | const [inline] |
Returns an iterator to the beginning.
const_iterator tvector< T >::end | ( | ) | const [inline] |
Returns an iterator to end.