A dynamic array especially for simple types and pointers. More...
#include <libppbase/base/DynamicArray.h>
Public Types | |
typedef size_t | size_type |
size type | |
Public Member Functions | |
DynamicArray () | |
Constructor. | |
DynamicArray (const DynamicArray< T > &src) | |
Copy constructor. | |
void | add (T item) |
Adds an item to the end of the array, possibly resizing the array if necessary. | |
void | clear () |
Removes all items. | |
T * | data () const |
Returns the array;. | |
bool | empty () const |
Checks if the array is empty. | |
void | erase (size_type pos, size_type count=1) |
Erases items from the array, thereby shrinking it. | |
T | get (size_type pos) const |
Gets an item from the array. | |
void | set (size_type pos, T item) |
Sets an item to a position, overwriting the existing item (the position must already exist). | |
size_type | size () const |
Returns the number of items in the array. | |
T | operator[] (size_type pos) const |
Gets an item from the array. | |
T & | operator[] (size_type pos) |
Gets an item from the array (lvalue). | |
DynamicArray< T > & | operator= (const DynamicArray< T > &src) |
Assignment operator. |
A dynamic array especially for simple types and pointers.
void base::DynamicArray< T >::add | ( | T | item | ) | [inline] |
Adds an item to the end of the array, possibly resizing the array if necessary.
item | the item to add |
T* base::DynamicArray< T >::data | ( | ) | const [inline] |
Returns the array;.
Referenced by base::DynamicArray< int >::operator=().
bool base::DynamicArray< T >::empty | ( | ) | const [inline] |
Checks if the array is empty.
void base::DynamicArray< T >::erase | ( | size_type | pos, | |
size_type | count = 1 | |||
) | [inline] |
Erases items from the array, thereby shrinking it.
pos | position to erase | |
count | number of items to erase |
T base::DynamicArray< T >::get | ( | size_type | pos | ) | const [inline] |
Gets an item from the array.
pos | item number to get |
T base::DynamicArray< T >::operator[] | ( | size_type | pos | ) | const [inline] |
Gets an item from the array.
pos | item number to get |
T& base::DynamicArray< T >::operator[] | ( | size_type | pos | ) | [inline] |
Gets an item from the array (lvalue).
pos | item number to get |
void base::DynamicArray< T >::set | ( | size_type | pos, | |
T | item | |||
) | [inline] |
Sets an item to a position, overwriting the existing item (the position must already exist).
pos | item number to set | |
item | the item to set |
size_type base::DynamicArray< T >::size | ( | ) | const [inline] |
Returns the number of items in the array.
Referenced by base::DynamicArray< int >::operator=().