In file code/C/generic.H:

template<class T> class GArray : public GObject

Code for the Dynamic Array template for storing pointers

Inheritance:


public members:

GArray()
~GArray()
Removes the dynamic array and calls delete on all of the elements
void Clear()
Clears the array without deleting elements
int SetSize(int asize)
Sets the size of the array to 'asize' elements
int GetSize()
Retrieves the current size of the array, in elements
int Append(T *)
Appends a value to the end of the array, returns index
T * &Last()
Returns the last value in the array
T *Pop()
Returns and removes the last value in the array (but does not delete)
T * &operator[](int index)
Overloaded index operator for the array
GArray <T>& operator=( GArray <T> &input)
Overloaded assignment operator for array (copy)
void Sort(int (*compar)(const void *, const void *))
Sort the array given a decision function

private members:

int vsize
The size in chunks
int size
The size in elements
T **array
Array of objects
int ChangeSize( int change)
Function that deals with resizing the array and deleting members
int change
Amount to change array relative to current size

Inherited from GObject:

public members:

friend ostream& operator<<(ostream& s, GObject &)

Documentation

This is a dynamic array that grows as needed. Holes are not allowed in the array so you can not grow the array by more than one element when allocating. You can explicitly SetSize() if you want to save time by preventing multiple calls to realloc().

Warning: This array automatically calls delete on all of the elements when the array is destroyed. If you want to get around this call Clear() before the array gets destroyed.


this class has no child classes.

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling