#include <array.h>
This class is similar to Store, except that adding elements to the end of the array is guaranteed to be a constant-time operation.
Random access is also constant-time, although slightly slower than the regular Store class. Use this class only when you need to add several elements to the array quickly.
Public Member Functions | |
ExtendableStore () | |
~ExtendableStore () | |
unsigned int | ItemCount () const |
Returns the number of items in the array. More... | |
void | SetItemCount (unsigned int iCount) |
Sets the logical size of the array. More... | |
void | Clear () |
Clears the array and deallocates its memory. More... | |
void | Add (const T &t) |
Adds a new item to the array, increasing the array size by 1. More... | |
void | Extend (unsigned int iIndex) |
Extends the logical size of the array. More... | |
void | Fill (T cPattern) |
Fills the array with a specified element. More... | |
unsigned int | IndexOf (const T &pValue) const |
Returns the first index of the element equal to pValue. More... | |
T & | Last (void) |
Returns the last item in the array, or 0 if the array is empty. More... | |
T & | operator[] (unsigned int iIndex) |
const T & | operator[] (unsigned int iIndex) const |
void | Serialize (Stream &s) |
|
inline |
|
inline |
Definition at line 712 of file array.h.
Sets the logical size of the array.
Returns true if successful.
If the new size is smaller than the current size, items at the end of the array will be discarded. If the new size is larger, then a new memory block will be allocated. In this case, the existing items will only be copied to the new block only if bKeepContent is set to true.
[in] | iCount | The new size of the array |
Definition at line 725 of file array.h.
|
inline |
Clears the array and deallocates its memory.
Definition at line 730 of file array.h.
|
inline |
Adds a new item to the array, increasing the array size by 1.
[in] | t | The element to be added to the end of the array |
Definition at line 741 of file array.h.
Extends the logical size of the array.
If the specified size is not larger than the current array, nothing will happen. Otherwise the logical size of the array will be extended to one more than the specified index. New memory will be allocated as necessary to hold the new items.
[in] | iIndex | The array index to extend to. For example, if you specify 7, the new array will contain 8 elements (indexed 0 to 7). |
Definition at line 755 of file array.h.
|
inline |
Fills the array with a specified element.
[in] | cPattern | The value to which every item in the array will be set |
Definition at line 780 of file array.h.
|
inline |
Returns the first index of the element equal to pValue.
Note this method requires that operator == be defined for the type of data stored in the array. Returns the index of the first occurance of pValue or 0xffffffff if the array does not contain pValue.
Definition at line 793 of file array.h.
|
inline |
Returns the last item in the array, or 0 if the array is empty.
Definition at line 802 of file array.h.
|
inline |
|
inline |
Definition at line 331 of file stream.h.