Inheritance diagram for Exponent::Collections::TPointerCollection< TypeName >:

Stores an internal array of pointer objects. Deletion is handled by the object deleter
that you provide during construction. These templates allow you to handle deletion of
objects in any way you require in a type safe way
Because of the object management system, you are fully safe to do something like the following
// Notice we add a new object directly, just like in java. The internal reference counting, depending on the pointer deleter // Will delete this directly array.addElement(new CString("Hello World"));
array.addElement(new double[32]);
for (long i = 0; i < array.getArraySize(); i++)
for (long i = 0; i < array.getInsertIndex(); i++)
TPointerCollection<CBool> boolArray; boolArray.addElement(new CBool(true)); boolArray.addElement(new CBool(false)); boolArray.addElement(new CBool(false)); // Now we step through and print the results for (long i = 0; i < boolArray.getInsertIndex(); i++) { // Get the pointer CBool *boolean = boolArray.elementAtIndex(i); // Check its valid if (boolean == NULL) continue; // Now you can process with the item // ... }
Definition at line 93 of file TPointerCollection.hpp.
| Exponent::Collections::TPointerCollection< TypeName >::qsortCompare |
Comparison function pointer. This is an example of the implementation of a comparison function.
To enable this to work properly with the qsort algorithm embedded inside the sort function you need to be capable of passing in double deferenced pointers
This is a legal conversion from void *. A couple of words about the parameters:
obj1 The first object to compare
obj2 The second object
You should return -1 if obj1 < obj2, 0 if obj1==obj2, +1 if obj1 > obj2
To call this comparision using the default sorting of the pointer collection, do something like this:.
array.sortArray((TPointerCollection<CClass>::qsortCompare)CClass::compareClasses);
Definition at line 128 of file TPointerCollection.hpp.
| Exponent::Collections::TPointerCollection< TypeName >::TPointerCollection | ( | TPointerDeleter< TypeName > * | pointerDeleter = &TPOINTER_COLLECTION_DEFAULT_DELETER |
) |
Construction
| pointerDeleter | The object that handles deletions |
| virtual Exponent::Collections::TPointerCollection< TypeName >::~TPointerCollection | ( | ) | [virtual] |
Destruction
| void Exponent::Collections::TPointerCollection< TypeName >::addElement | ( | TypeName * | pointer | ) |
Add a pointer to the array
| pointer | The pointer to add |
| void Exponent::Collections::TPointerCollection< TypeName >::addElementAtIndex | ( | const long | index, | |
| TypeName * | pointer | |||
| ) |
Insert a pointer at a specific index
| index | The index to store at, if an object is there it is deleted | |
| pointer | The pointer to add |
| void Exponent::Collections::TPointerCollection< TypeName >::clearArray | ( | ) |
Clear the array
| const TypeName* Exponent::Collections::TPointerCollection< TypeName >::constElementAtIndex | ( | const long | index | ) | const |
Get the element at a specific index
| index | The index of the pointer |
| TypeName* | The object requested or NULL on error |
| void Exponent::Collections::TPointerCollection< TypeName >::deletePointerAtIndex | ( | const long | index | ) |
Delete a pointer at an index
| index | Index of the pointer to delete |
| TypeName* Exponent::Collections::TPointerCollection< TypeName >::elementAtIndex | ( | const long | index | ) |
Get the element at a specific index
| index | The index of the pointer |
| TypeName* | The object requested or NULL on error |
| void Exponent::Collections::TPointerCollection< TypeName >::expand | ( | ) | [protected] |
Expand the array
| void Exponent::Collections::TPointerCollection< TypeName >::freePointers | ( | ) | [protected] |
Free pointers -> deleteds (but not allways) all pointers
| long Exponent::Collections::TPointerCollection< TypeName >::getArraySize | ( | ) | const |
Get the size of the array
| long | The size of the array |
| long Exponent::Collections::TPointerCollection< TypeName >::getIndexOfPointer | ( | const TypeName * | pointer | ) |
Get the index of a pointer
| pointer | The pointer to find |
| long | The index of the pointer or TPOINTERCOLLECTION_FAILED_TO_FIND_POINTER on error |
| long Exponent::Collections::TPointerCollection< TypeName >::getInsertIndex | ( | ) | const |
Get the insert index
| long | The current end pointer of the array |
| TypeName** Exponent::Collections::TPointerCollection< TypeName >::getMutableInternalBuffer | ( | ) | [inline] |
Get the internal buffer
| const | TypeName ** The internal buffer |
Definition at line 274 of file TPointerCollection.hpp.
| long Exponent::Collections::TPointerCollection< TypeName >::getNumberOfElementsUntilNextGrow | ( | ) |
Get number of elements until next grow
| long | The number of elements that can be added before the array has to grow |
| void Exponent::Collections::TPointerCollection< TypeName >::initialise | ( | ) | [protected] |
Initialise the unit
| bool Exponent::Collections::TPointerCollection< TypeName >::isArrayEmpty | ( | ) | const |
Is the array empty?
| bool | True if array size is zero |
| bool Exponent::Collections::TPointerCollection< TypeName >::isPointerInArray | ( | const TypeName * | pointer | ) |
Is pointer in array
| pointer | The object to look for |
| bool | True if this object is stored in the array, false otherwise |
| TypeName* Exponent::Collections::TPointerCollection< TypeName >::operator[] | ( | const long | index | ) |
Index operator
| TypeName* | The object or null on error |
| void Exponent::Collections::TPointerCollection< TypeName >::registerPointerDeleter | ( | TPointerDeleter< TypeName > * | pointerDeleter = &TPOINTER_COLLECTION_DEFAULT_DELETER |
) | [inline] |
Set the pointer deleter
| pointerDeleter | The object that handles deletions |
Definition at line 266 of file TPointerCollection.hpp.
| TypeName* Exponent::Collections::TPointerCollection< TypeName >::removeElementAtIndexWithoutDeletion | ( | const long | index | ) |
Remove the pointer at the index without deletion
| index | The index of the pointer to remove |
| TypeName* | The object removed from the array |
| void Exponent::Collections::TPointerCollection< TypeName >::reorder | ( | const bool | resize = true |
) |
Reorder the array to remove dead pointers, resize shrinks the array
| resize | If true will remove any remaining null pointers at the end of the array, if false array may be bigger than usage |
| void Exponent::Collections::TPointerCollection< TypeName >::setGrowSize | ( | const long | growSize = TPOINTERCOLLECTION_DEFAULT_GROW_SIZE |
) |
Set the grow size
| growSize | The amount that the array size should be increased by |
| void Exponent::Collections::TPointerCollection< TypeName >::sortArray | ( | qsortCompare | compareFunction | ) |
Sort the array
| compareFunction | The comparison function to use |
| void Exponent::Collections::TPointerCollection< TypeName >::swapIndexes | ( | const long | index1, | |
| const long | index2 | |||
| ) |
Swap two pointers
| index1 | The index of the first pointer | |
| index2 | The index of the second pointer |
TypeName** Exponent::Collections::TPointerCollection< TypeName >::m_array [protected] |
The internal array
Definition at line 305 of file TPointerCollection.hpp.
Referenced by Exponent::Collections::TPointerCollection< Exponent::GUI::Controls::CMenuItem >::getMutableInternalBuffer().
long Exponent::Collections::TPointerCollection< TypeName >::m_arraySize [protected] |
The size of the array
Definition at line 307 of file TPointerCollection.hpp.
long Exponent::Collections::TPointerCollection< TypeName >::m_growSize [protected] |
how many extra area do we require when we run out
Definition at line 308 of file TPointerCollection.hpp.
long Exponent::Collections::TPointerCollection< TypeName >::m_insertIndex [protected] |
The current end point of the array < m_arraySize
Definition at line 309 of file TPointerCollection.hpp.
TPointerDeleter<TypeName>* Exponent::Collections::TPointerCollection< TypeName >::m_pointerDeletionHandler [protected] |
Deletion handler
Definition at line 306 of file TPointerCollection.hpp.
Referenced by Exponent::Collections::TPointerCollection< Exponent::GUI::Controls::CMenuItem >::registerPointerDeleter().
TObjectDeleter<TypeName> Exponent::Collections::TPointerCollection< TypeName >::TPOINTER_COLLECTION_DEFAULT_DELETER [static] |
The default handler for pointer deletion
Definition at line 105 of file TPointerCollection.hpp.
TObjectNuller<TypeName> Exponent::Collections::TPointerCollection< TypeName >::TPOINTER_COLLECTION_DEFAULT_NULLER [static] |
The defulat handler for nulling pointers
Definition at line 106 of file TPointerCollection.hpp.
const long Exponent::Collections::TPointerCollection< TypeName >::TPOINTERCOLLECTION_DEFAULT_GROW_SIZE = 32 [static] |
Default amount to grow the array by
Definition at line 110 of file TPointerCollection.hpp.
const long Exponent::Collections::TPointerCollection< TypeName >::TPOINTERCOLLECTION_FAILED_TO_FIND_POINTER = -1 [static] |
We failed to find a pointer
Definition at line 111 of file TPointerCollection.hpp.