![]() |
Public API Reference |
#include <array.h>
Public Methods | |
csArray (int icapacity=0, int ithreshold=0) | |
Initialize object to have initial capacity of 'icapacity' elements, and to increase storage by 'ithreshold' each time the upper bound is exceeded. More... | |
csArray (const csArray &other) | |
Copy constructor just copies all data. More... | |
void | TransferTo (csArray< T > &destination) |
Transfer the entire contents of one array to the other. More... | |
void | DeleteAll () |
Clear entire vector, releasing all memory. More... | |
void | Truncate (int n) |
Truncate array to specified number of elements. More... | |
void | SetLength (int n, T const &what) |
Set the actual number of items in this array. More... | |
void | Empty () |
Remove all elements. More... | |
~csArray () | |
Destroy the container. More... | |
int | Length () const |
Query vector length. More... | |
int | Capacity () const |
Query vector capacity. Note that you should rarely need to do this. More... | |
void | SetCapacity (int n) |
Set vector capacity to approximately 'n' elements. More... | |
void | ShrinkBestFit () |
Make the array just as big as it needs to be. More... | |
T const & | Get (int n) const |
Get an element (const). More... | |
T & | Get (int n) |
Get an element (non-const). More... | |
T const & | operator[] (int n) const |
Get an element (const). More... | |
T & | operator[] (int n) |
Get an element (non-const). More... | |
int | Find (T const &which) const |
Find a element in array and return its index (or -1 if not found). More... | |
int | Push (T const &what) |
Push an element onto the tail end of the array. Returns index of element. More... | |
T | Pop () |
Pop an element from tail end of array. More... | |
T const & | Top () const |
Return the top element but do not remove it. More... | |
bool | DeleteIndex (int n) |
Delete element number 'n' from vector. More... | |
void | DeleteRange (int start, int end) |
Delete a given range (inclusive). More... | |
bool | Delete (T const &item) |
Delete the given element from vector. More... | |
bool | Insert (int n, T const &item) |
Insert element 'item' before element 'n'. More... |
The objects in this class are constructed via copy-constructor and are destroyed when they are removed from the array or the array is destroyed. Note: If you want to store reference-counted object pointers (such as iSomething*), then you should look at csRefArray instead of this class.
Definition at line 36 of file array.h.
|
Initialize object to have initial capacity of 'icapacity' elements, and to increase storage by 'ithreshold' each time the upper bound is exceeded.
|
|
Copy constructor just copies all data.
|
|
Destroy the container.
|
|
Query vector capacity. Note that you should rarely need to do this.
|
|
Delete the given element from vector.
|
|
Clear entire vector, releasing all memory.
Definition at line 136 of file array.h. Referenced by csArray< csHashBucket >::ShrinkBestFit, csArray< csHashBucket >::TransferTo, and csArray< csHashBucket >::~csArray. |
|
Delete element number 'n' from vector.
Definition at line 316 of file array.h. Referenced by csArray< csHashBucket >::Delete. |
|
Delete a given range (inclusive). This routine will clamp start and end to the size of the array. |
|
Remove all elements. Similar to DeleteAll(), but does not release memory used by the array itself, thus making it more efficient for cases when the number of contained elements will fluctuate. |
|
Find a element in array and return its index (or -1 if not found).
Definition at line 272 of file array.h. Referenced by csArray< csHashBucket >::Delete. |
|
Get an element (non-const).
|
|
Get an element (const).
Definition at line 246 of file array.h. Referenced by csArray< csHashBucket >::operator[]. |
|
Insert element 'item' before element 'n'.
|
|
Query vector length.
Definition at line 204 of file array.h. Referenced by csArray< csHashBucket >::csArray, csBlockAllocator::Dump, csArray< csHashBucket >::Find, csArray< csHashBucket >::SetCapacity, csArray< csHashBucket >::SetLength, and csBlockAllocator::~csBlockAllocator. |
|
Get an element (non-const).
|
|
Get an element (const).
|
|
Pop an element from tail end of array.
|
|
Push an element onto the tail end of the array. Returns index of element.
Definition at line 281 of file array.h. Referenced by csArray< csHashBucket >::csArray, and csBlockAllocator::csBlockAllocator. |
|
Set vector capacity to approximately 'n' elements. Never sets the capacity to fewer than the current number of elements in the array. See Truncate() or SetLength() if you need to adjust the number of actual array elements. |
|
Set the actual number of items in this array. This can be used to shrink an array (works like Truncate() then in which case it will properly destroy all truncated objects) or to enlarge an array in which case it will properly set the new capacity and construct all new items based on the given item. |
|
Make the array just as big as it needs to be. This is useful in cases where you know the array isn't going to be modified anymore in order to preserve memory. |
|
Return the top element but do not remove it.
|
|
Transfer the entire contents of one array to the other. The end result will be that this array will be completely empty and the other array will have all items that originally were in this array. This operation is very efficient. |
|
Truncate array to specified number of elements. The new number of elements cannot exceed the current number of elements. Use SetLength() for a more general way to enlarge the array. Definition at line 154 of file array.h. Referenced by csArray< csHashBucket >::Empty, and csArray< csHashBucket >::SetLength. |