
Public Types | |
| typedef TMCIterator < T, TMCClassArray < T > > | iterator |
| typedef TMCConstIterator< T, TMCClassArray< T > > | const_iterator |
Public Member Functions | |
| TMCClassArray (void) | |
| TMCClassArray (uint32 initialCount) | |
| TMCClassArray (uint32 initialCount, uint32 initialSpace, uint32 initialGrowSize) | |
| TMCClassArray (const TMCClassArray< T > &inFromArray) | |
| TMCClassArray (T *const &baseAddress, boolean inAquireMemory, uint32 elemCount, uint32 elemSpace) | |
| TMCClassArray (TMCClassArray< T > &array, uint32 elemStart, uint32 elemCount) | |
| ~TMCClassArray (void) | |
| TMCClassArray< T > & | operator= (const TMCClassArray< T > &fromArray) |
| void | ArrayFree (void) |
| boolean | IsValid (void) const |
| MCErr | IsIndexInvalid (int32 i) const |
| int8 * | BaseAddress (void) |
| const int8 * | BaseAddress (void) const |
| uint32 | GetElemSize (void) const |
| uint32 | GetGrowSize (void) const |
| uint32 | GetElemSpace (void) const |
| uint32 | GetElemCount (void) const |
| boolean | ExternalMemory () |
| boolean | GetSmartGrow (void) const |
| T * | ArrayData (void) |
| const T * | ArrayData (void) const |
| boolean | IsInArray (const T *data) const |
| void | SetValid (boolean valid) |
| void | SetGrowSize (uint32 g) |
| void | SetSmartGrow () |
| boolean | SetElemSpace (uint32 n) |
| boolean | SetElemCount (uint32 n) |
| boolean | AddElemCount (uint32 n) |
| const_iterator | Begin (void) const |
| iterator | Begin (void) |
| const_iterator | End (void) const |
| iterator | End (void) |
| T & | FirstElem (void) |
| const T & | FirstElem (void) const |
| T & | LastElem (void) |
| const T & | LastElem (void) const |
| void | Erase (const iterator &elementToErase) |
| void | Erase (const iterator &start, const iterator &end) |
| boolean | CopyElems (const TMCClassArray< T > &fromArray, uint32 firstIndex, uint32 nbItems, uint32 insertIndex) |
| boolean | Append (const TMCClassArray< T > &fromArray) |
| void | FillWithValue (const T &inValue, uint32 inStart=kBeginIndex, uint32 inLength=kUnusedIndex) |
| void | Swap (TMCClassArray< T > &fromArray) |
| T * | Pointer (uint32 i) |
| const T * | Pointer (uint32 i) const |
| T & | operator[] (uint32 i) |
| const T & | operator[] (uint32 i) const |
| void | SetElem (uint32 index, const T &data) |
| void | GetElem (uint32 index, T &data) const |
| boolean | AddElem (const T &data) |
| T & | AddElem () |
| boolean | InsertElem (uint32 index, const T &data) |
| void | RemoveElem (uint32 index, uint32 count) |
| boolean | CompactArray (void) |
| uint32 | FindElem (const T &elemToFind) const |
| void | RemoveElem (T &elemToRemove) |
Protected Member Functions | |
| boolean | ArrayAlloc (uint32 initialCount, uint32 initialSpace, uint32 initialGrowSize) |
| boolean | ArrayAllocFromBuffer (T *baseAddress, boolean inAquireMemory, uint32 elemCount, uint32 elemSpace) |
| void | UpdateDataPointer (void) |
| void | ZeroInternals (void) |
| void | Construct (T *inDataStart, uint32 numConstruct, const T &inInitValue) |
| void | Destruct (T *inDataStart, uint32 numDestruct) |
Protected Attributes | |
| uint32 | fElemCount |
| The number of elements in use. | |
| uint32 | fElemSpace |
| The number of elements allocated (unconstructed). | |
| uint32 | fArrayFlags |
| Flags that control the behavior of the array. | |
| T * | fArrayData |
| The memory block used by the array. | |
Indexes to access the Array classes are ZERO based (array[0] gives you the first element)
Arrays grows dynamically as you add elements, so it is very dangerous to keep pointers to elements of the array: if the array is reallocated, your pointers will become invalid. In this case, you should use indexes. For better efficiency, preallocate the number of elements you'll need (or use an estimation of the space if possible).
In eSmartGrow mode (the default), the size of the extra space added when the array is reallocated (the grow size) depends on the number of elements already in the array. Otherwise, a constant grow size is used.
Other array classes are: TMCArray, TMCPtrArray, TMCCountedPtrArray, and TMCExtensibleArray.
| typedef TMCIterator<T, TMCClassArray<T> > TMCClassArray< T >::iterator |
| typedef TMCConstIterator<T, TMCClassArray<T> > TMCClassArray< T >::const_iterator |
| TMCClassArray< T >::TMCClassArray | ( | void | ) | [inline] |
Creates an empty array
| TMCClassArray< T >::TMCClassArray | ( | uint32 | initialCount | ) | [inline, explicit] |
Constructs an array with a certain number of elements already accessible (and constructed).
| initialCount | initial number of array elements. |
| TMCClassArray< T >::TMCClassArray | ( | uint32 | initialCount, | |
| uint32 | initialSpace, | |||
| uint32 | initialGrowSize | |||
| ) | [inline] |
Constructs an array with a certain number of elements already accessible (and constructed), and/or some extra space to extend the array without reallocating it.
| initialCount | Initial number of array elements. | |
| initialSpace | Pre-allocate space for this many elements (must be bigger than initialCount). | |
| initialGrowSize | How many elements to grow the array when we grow past the end |
| TMCClassArray< T >::TMCClassArray | ( | const TMCClassArray< T > & | inFromArray | ) | [inline] |
Copy constructor: Construct an array from an existing array.
| TMCClassArray< T >::TMCClassArray | ( | T *const & | baseAddress, | |
| boolean | inAquireMemory, | |||
| uint32 | elemCount, | |||
| uint32 | elemSpace | |||
| ) | [inline] |
Constructs an array from existing memory.
| baseAddress | External memory to use for this array. | |
| inAquireMemory | Should we take possession this memory. | |
| elemCount | The number of array elements in use in that memory. | |
| elemSpace | The number of array elements that can be used in that memory. |
| TMCClassArray< T >::TMCClassArray | ( | TMCClassArray< T > & | array, | |
| uint32 | elemStart, | |||
| uint32 | elemCount | |||
| ) | [inline] |
Constructs an alias to an existing array.
| array | Alias elements from this array. | |
| elemStart | Start alias here. | |
| elemCount | Alias this many elements. |
| TMCClassArray< T >::~TMCClassArray | ( | void | ) | [inline] |
Destructs the elements of the array and frees the memory (if the array owns it).
| TMCClassArray< T > & TMCClassArray< T >::operator= | ( | const TMCClassArray< T > & | fromArray | ) | [inline] |
operator=: Assignment operator copies all the data from one array to another.
| boolean TMCClassArray< T >::ArrayAlloc | ( | uint32 | initialCount, | |
| uint32 | initialSpace, | |||
| uint32 | initialGrowSize | |||
| ) | [inline, protected] |
!!! DO NOT CALL THIS !!!
| boolean TMCClassArray< T >::ArrayAllocFromBuffer | ( | T * | baseAddress, | |
| boolean | inAquireMemory, | |||
| uint32 | elemCount, | |||
| uint32 | elemSpace | |||
| ) | [inline, protected] |
!!! DO NOT CALL THIS !!!
| void TMCClassArray< T >::ArrayFree | ( | void | ) | [inline] |
Frees all the memory held by this array (unless it uses external memory). And sets the element count to 0.
| boolean TMCClassArray< T >::IsValid | ( | void | ) | const [inline] |
IsValid(): Check to see if the class is valid.
| MCErr TMCClassArray< T >::IsIndexInvalid | ( | int32 | i | ) | const [inline] |
returns kNoErr if the given index is valid, kOutOfRangeError otherwise (use with ThrowIfError(array.IsIndexInvalid(i);)
| int8* TMCClassArray< T >::BaseAddress | ( | void | ) | [inline] |
Returns the address at which the elements of the array begin
| const int8* TMCClassArray< T >::BaseAddress | ( | void | ) | const [inline] |
Returns the address at which the elements of the array begin
| uint32 TMCClassArray< T >::GetElemSize | ( | void | ) | const [inline] |
Returns the size of one element
| uint32 TMCClassArray< T >::GetGrowSize | ( | void | ) | const [inline] |
Returns the size by which the array grows
| uint32 TMCClassArray< T >::GetElemSpace | ( | void | ) | const [inline] |
Returns the number of elements that can be stored in the array (before the next reallocation)
| uint32 TMCClassArray< T >::GetElemCount | ( | void | ) | const [inline] |
Returns the actual number of (valid) elements in the array. Those elements can be accessed with the operator []
| boolean TMCClassArray< T >::ExternalMemory | ( | ) | [inline] |
Returns true if the array doesn't own its memory
| boolean TMCClassArray< T >::GetSmartGrow | ( | void | ) | const [inline] |
Returns true if the grow size is dynamic
| T* TMCClassArray< T >::ArrayData | ( | void | ) | [inline] |
Returns a pointer to the first element
| const T* TMCClassArray< T >::ArrayData | ( | void | ) | const [inline] |
Returns a pointer to the first element
| boolean TMCClassArray< T >::IsInArray | ( | const T * | data | ) | const [inline] |
Returns true if the element is in the array
| void TMCClassArray< T >::SetValid | ( | boolean | valid | ) | [inline] |
Sets the valid flag to true
| void TMCClassArray< T >::SetGrowSize | ( | uint32 | g | ) | [inline] |
Sets the growSize (and sets the eSmartGrow flag to false)
| void TMCClassArray< T >::SetSmartGrow | ( | ) | [inline] |
Sets the eSmartGrow flag and computes the maximum grow size (in elements count)
| boolean TMCClassArray< T >::SetElemSpace | ( | uint32 | n | ) | [inline] |
Set the number of elements to have memory allocated for. Note: This memory is unconstructed, uninitialied and isn't considered part of the array until the element count reaches the memory.
| boolean TMCClassArray< T >::SetElemCount | ( | uint32 | n | ) | [inline] |
Set the number of elements in the array.
| boolean TMCClassArray< T >::AddElemCount | ( | uint32 | n | ) | [inline] |
Add the passed in number of elemens to the array.
| const_iterator TMCClassArray< T >::Begin | ( | void | ) | const [inline] |
Returns a reference to the begining iterator for the array.
| iterator TMCClassArray< T >::Begin | ( | void | ) | [inline] |
Returns a reference to the begining iterator for the array.
| const_iterator TMCClassArray< T >::End | ( | void | ) | const [inline] |
Returns a reference to the ending iterator for the array.
| iterator TMCClassArray< T >::End | ( | void | ) | [inline] |
Returns a reference to the ending iterator for the array.
| T& TMCClassArray< T >::FirstElem | ( | void | ) | [inline] |
Returns a reference to the first element in the array.
| const T& TMCClassArray< T >::FirstElem | ( | void | ) | const [inline] |
Returns a reference to the first element in the array.
| T& TMCClassArray< T >::LastElem | ( | void | ) | [inline] |
Returns a reference to the last element in the array.
| const T& TMCClassArray< T >::LastElem | ( | void | ) | const [inline] |
Returns a reference to the last element in the array.
| void TMCClassArray< T >::Erase | ( | const iterator & | elementToErase | ) | [inline] |
Erases a single element in the array that is referenced by the iterator.
| void TMCClassArray< T >::Erase | ( | const iterator & | start, | |
| const iterator & | end | |||
| ) | [inline] |
Erases a range of elements in the array from the startIterator to the endIterator.
| boolean TMCClassArray< T >::CopyElems | ( | const TMCClassArray< T > & | fromArray, | |
| uint32 | firstIndex, | |||
| uint32 | nbItems, | |||
| uint32 | insertIndex | |||
| ) | [inline] |
Copy elements from one array to another.
| boolean TMCClassArray< T >::Append | ( | const TMCClassArray< T > & | fromArray | ) | [inline] |
Append one array on to the end of another.
| void TMCClassArray< T >::FillWithValue | ( | const T & | inValue, | |
| uint32 | inStart = kBeginIndex, |
|||
| uint32 | inLength = kUnusedIndex | |||
| ) | [inline] |
Fill an array range with the value passed in.
| void TMCClassArray< T >::Swap | ( | TMCClassArray< T > & | fromArray | ) | [inline] |
Swaps the contents of two arrays.
| T* TMCClassArray< T >::Pointer | ( | uint32 | i | ) | [inline] |
Returns a pointer to the data at the passed in index.
| const T* TMCClassArray< T >::Pointer | ( | uint32 | i | ) | const [inline] |
Returns a pointer to the data at the passed in index.
| T& TMCClassArray< T >::operator[] | ( | uint32 | i | ) | [inline] |
Returns a reference to the data at the passed in index.
| const T& TMCClassArray< T >::operator[] | ( | uint32 | i | ) | const [inline] |
Returns a reference to the data at the passed in index.
| void TMCClassArray< T >::SetElem | ( | uint32 | index, | |
| const T & | data | |||
| ) | [inline] |
Set the contents of arrray index to the passed in data reference.
| void TMCClassArray< T >::GetElem | ( | uint32 | index, | |
| T & | data | |||
| ) | const [inline] |
Get the contents of arrray index into the passed in data reference.
| boolean TMCClassArray< T >::AddElem | ( | const T & | data | ) | [inline] |
Add an element to the end of the array and assign it the data reference that is passed in.
| T & TMCClassArray< T >::AddElem | ( | ) | [inline] |
Add an element to the end of the array and returns a reference to it.
| boolean TMCClassArray< T >::InsertElem | ( | uint32 | index, | |
| const T & | data | |||
| ) | [inline] |
Inserts one element at the given index
| index | where to insert | |
| data | the data to insert |
| void TMCClassArray< T >::RemoveElem | ( | uint32 | index, | |
| uint32 | count | |||
| ) | [inline] |
Remove one or more elements from the array starting from the passed in index.
| boolean TMCClassArray< T >::CompactArray | ( | void | ) | [inline] |
Get rid of any space that has been allocated to the array and isn't being used.
| uint32 TMCClassArray< T >::FindElem | ( | const T & | elemToFind | ) | const [inline] |
Finds the index in this array of the given element
| elemToFind | the element to search for |
| void TMCClassArray< T >::RemoveElem | ( | T & | elemToRemove | ) | [inline] |
Removes (only) one occurence of an element (after searching for it)
| elemToRemove | the element to remove. |
| void TMCClassArray< T >::UpdateDataPointer | ( | void | ) | [inline, protected] |
| void TMCClassArray< T >::ZeroInternals | ( | void | ) | [inline, protected] |
| void TMCClassArray< T >::Construct | ( | T * | inDataStart, | |
| uint32 | numConstruct, | |||
| const T & | inInitValue | |||
| ) | [inline, protected] |
| void TMCClassArray< T >::Destruct | ( | T * | inDataStart, | |
| uint32 | numDestruct | |||
| ) | [inline, protected] |
uint32 TMCClassArray< T >::fElemCount [protected] |
The number of elements in use.
uint32 TMCClassArray< T >::fElemSpace [protected] |
The number of elements allocated (unconstructed).
uint32 TMCClassArray< T >::fArrayFlags [protected] |
Flags that control the behavior of the array.
T* TMCClassArray< T >::fArrayData [protected] |
The memory block used by the array.
1.5.3