gml_TDynamicArray Class Template Reference

#include <gml_DynamicArray.h>

Collaboration diagram for gml_TDynamicArray:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class T>
class gml_TDynamicArray< T >

An array of fixed sized elements that can grow over time. Growth is by block of elements (not one element every time). Finding a free slot in the array is somewhat optimized using a bitmap of used slots.


Public Member Functions

gml_TError Init (gml_TBlockSize nbElem=sDefaultNbElem, gml_TBlockSize nbIncrease=sDefaultNbIncrease)
 Initializes the array with nbElem elements of size elemSize. When a new element is required and the array is full, the array is re-allocated with nbIncrease more elements.
void Dispose ()
 Release the array resources.
T * Base ()
 Returns the base address of the array.
T * GetElem (gml_TBlockSize *index=(gml_TBlockSize *) NULL)
 Get a pointer to a new element from the array. If index is not NULL, <*index> recieves the index of the element in the array.
void ReleaseElem (T *elem)
 Flag elem as not being used anymore.

Static Public Attributes

static const gml_TBlockSize sDefaultNbElem = 20
 default starting number of elements in an array
static const gml_TBlockSize sDefaultNbIncrease = 20
 default additional slots allocated on array growth

Protected Member Functions

gml_TError Allocate (gml_TBlockSize nbElem)

Protected Attributes

gml_TBlockSize fNbIncrease
 size of the increased allocation when a new element is < needed and the array is full
T * fMem
 memory allocated for the array
gml_TBlockSize fNbElem
 number of elements that the current memory can store
gml_TBlockSize fInUse
 number of current allocated elements
UInt32fBitmap
 bitmap of elements in use
gml_TBlockSize fBMSize
 size (number of 32 bit words) of used bitmap

Member Function Documentation

T* Base (  )  [inline]

Returns the base address of the array.

Warning:
The base address in only valid from the Base() call until the next call to GetElem(): GetElem() may require a relocation of the memory if the array is full.

T * GetElem ( gml_TBlockSize index = (gml_TBlockSize *) NULL  )  [inline]

Get a pointer to a new element from the array. If index is not NULL, <*index> recieves the index of the element in the array.

Returns:
A pointer to the new element everything goes ok. NULL if there is no more memory to grow the array.


The documentation for this class was generated from the following files:
Generated on Tue Jun 12 14:03:28 2007 for gml by Doxygen 1.5.2.