Collaboration diagram for CThingArray:
Public Member Functions | |
CThingArray () | |
The constructor for CThingArray simply calls the Construct function. | |
~CThingArray () | |
The destructor for CThingArray simply calls the Destruct function. | |
void | Construct () |
The Construct function readies the internal structure of the CThingArray for use. | |
void | Destruct () |
The Destruct function cleans up the internal structure of the CThingArray. | |
void | AddCThing (CThing *t) |
The AddCThing function adds a new CThing to the CThingArray. | |
CThing * | ReturnAt (unsigned long i) const |
The ReturnAt function is used to get a CThing stored in a specific position within the array. | |
void | AddAt (unsigned long i, CThing *t) |
The AddAt function replaces an element of the array with a new CThing. | |
void | RemoveAt (unsigned long i) |
The RemoveAt function removes the CThing at a given position from the Array. | |
unsigned long | NumberOfThings () const |
The NumberOfThings function returns the number of elements currently in the array. | |
Public Attributes | |
CThing ** | ar |
The internal array data. | |
unsigned long | size |
The number of available elements in the internal array. | |
unsigned long | used |
The number of elements in the internal array that are currently used. |
The CThingArray class is used almost universally whenever a list of CThings needs to be stored. The CThingArray class does not handle reference counting or garbage collection. The array itself stores pointers to CThings, not copies of them. Whenever array operations are mentioned remember that you are dealing with pointers to these CThings. This class' implementation is nearly identical to LongArray, Int8Array, and PointerArray.
|
The constructor for CThingArray simply calls the Construct function.
|
|
The destructor for CThingArray simply calls the Destruct function.
|
|
The AddAt function replaces an element of the array with a new CThing. If you try to replace an element at a position greater than the number of elements in the array nothing will happen. This was the source of more than one error, so prehaps it is best to think of the function as being called ReplaceAt.
|
|
The AddCThing function adds a new CThing to the CThingArray. If there is not enough storage in the internal array it will be expanded. The new CThing is always added to the end of the array. The size of the array is expanded by 8 (8 pointer not 8 bytes) everytime it needs to be resized.
|
|
The Construct function readies the internal structure of the CThingArray for use. To reset a CThingArray you can call Destruct on it followed by a call to Construct.
|
|
The Destruct function cleans up the internal structure of the CThingArray. Destruct does not affect the CThings that were stored in it at the time in any way.
|
|
The RemoveAt function removes the CThing at a given position from the Array. The old CThing is replaced by what was previously the last CThing in the array and then the active part of the array is reduced by one. The RemoveAt function does not preserve the order of elements. Attempting to remove a position greater than the number of elements in the array has no effect.
|
|
The ReturnAt function is used to get a CThing stored in a specific position within the array. If you attempt to return a CThing at a position greater than the number of elements stored in the array NULL will be the result.
|