Public Types | Public Member Functions

base::DynamicArray< T > Class Template Reference

A dynamic array especially for simple types and pointers. More...

#include <libppbase/base/DynamicArray.h>

List of all members.

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.
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.
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.

Detailed Description

template<class T>
class base::DynamicArray< T >

A dynamic array especially for simple types and pointers.

Author:
Christoph Schwarz
Version:
$Id: DynamicArray.h 21 2010-09-05 04:18:17Z cschwarz1 $

Member Function Documentation

template<class T>
void base::DynamicArray< T >::add ( item  )  [inline]

Adds an item to the end of the array, possibly resizing the array if necessary.

Parameters:
item the item to add
template<class T>
T* base::DynamicArray< T >::data (  )  const [inline]

Returns the array;.

Returns:
the array, may be NULL if it is empty

Referenced by base::DynamicArray< int >::operator=().

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

Checks if the array is empty.

Returns:
true if it is empty, false if there is at least one item in it
template<class T>
void base::DynamicArray< T >::erase ( size_type  pos,
size_type  count = 1 
) [inline]

Erases items from the array, thereby shrinking it.

Parameters:
pos position to erase
count number of items to erase
template<class T>
T base::DynamicArray< T >::get ( size_type  pos  )  const [inline]

Gets an item from the array.

Parameters:
pos item number to get
template<class T>
T base::DynamicArray< T >::operator[] ( size_type  pos  )  const [inline]

Gets an item from the array.

Parameters:
pos item number to get
template<class T>
T& base::DynamicArray< T >::operator[] ( size_type  pos  )  [inline]

Gets an item from the array (lvalue).

Parameters:
pos item number to get
template<class T>
void base::DynamicArray< T >::set ( size_type  pos,
item 
) [inline]

Sets an item to a position, overwriting the existing item (the position must already exist).

Parameters:
pos item number to set
item the item to set
template<class T>
size_type base::DynamicArray< T >::size (  )  const [inline]

Returns the number of items in the array.

Returns:
number of items

Referenced by base::DynamicArray< int >::operator=().


The documentation for this class was generated from the following file: