![]() |
Public API Reference |
#include <array.h>
Public Types | |
typedef int | ArrayCompareFunction (T const &item1, T const &item2) |
This function prototype is used for csArray::InsertSorted(). More... | |
typedef int | ArrayCompareKeyFunction (T const &item1, void *item2) |
This function prototype is used for csArray::FindKey(). More... | |
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 &source) | |
Copy constructor. More... | |
csArray< T > & | operator= (const csArray &other) |
Assignment operator. More... | |
int | Length () const |
Return the number of elements in the Array. More... | |
int | Capacity () const |
Query vector capacity. Note that you should rarely need to do this. More... | |
void | TransferTo (csArray &destination) |
Transfer the entire contents of one array to the other. More... | |
void | SetLength (int n, T const &what) |
Set the actual number of items in this array. More... | |
void | SetLength (int n) |
Set vector length to n. More... | |
T & | Get (int n) |
Get an element (non-const). More... | |
T & | GetExtend (int n) |
Get an item from the array. More... | |
T & | operator[] (int n) |
Get an element (non-const). More... | |
void | Put (int n, T const &what) |
Put an element at some position. More... | |
int | FindKey (void *key, ArrayCompareKeyFunction *comparekey) const |
Find an element based on some key. 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 | Insert (int n, T const &item) |
Insert element 'item' before element 'n'. More... | |
csArray< T > | Section (int low, int high) const |
Get the portion of the array between low and high inclusive. More... | |
int | FindSortedKey (void *key, ArrayCompareKeyFunction *comparekey=DefaultCompareKey, int *candidate=0) const |
Find an element based on some key, using a csArrayCompareKeyFunction. More... | |
int | InsertSorted (const T &item, ArrayCompareFunction *compare=DefaultCompare, int *equal_index=0) |
Insert an element at a sorted position, using a csArrayCompareFunction. More... | |
int | Find (T const &which) const |
Find a element in array and return its index (or -1 if not found). More... | |
void | Sort (ArraySortCompareFunction *compare) |
Sort array. More... | |
T const & | Get (int n) const |
Get an element (const). More... | |
T const & | operator[] (int n) const |
Get a const reference. More... | |
void | DeleteAll () |
Clear entire vector. More... | |
void | Truncate (int n) |
Truncate array to specified number of elements. More... | |
void | Empty () |
Remove all elements. 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... | |
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... | |
Iterator | GetIterator () const |
Returns an Iterator which traverses the Array. More... | |
Static Public Methods | |
int | DefaultCompare (T const &item1, T const &item2) |
The default ArrayCompareFunction for InsertSorted(). More... | |
int | DefaultCompareKey (T const &item1, void *p) |
The default ArrayCompareKeyFunction for FindKey(). More... | |
Protected Methods | |
void | InitRegion (int start, int count) |
Initialize a region. 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 61 of file array.h.
|
This function prototype is used for csArray::InsertSorted().
Definition at line 119 of file array.h. Referenced by csArray< iLightingProcessData *, csRefArrayElementHandler< iLightingProcessData * > >::InsertSorted. |
|
This function prototype is used for csArray::FindKey().
Definition at line 121 of file array.h. Referenced by csArray< iLightingProcessData *, csRefArrayElementHandler< iLightingProcessData * > >::FindKey, and csArray< iLightingProcessData *, csRefArrayElementHandler< iLightingProcessData * > >::FindSortedKey. |
|
Initialize object to have initial capacity of 'icapacity' elements, and to increase storage by 'ithreshold' each time the upper bound is exceeded.
|
|
Copy constructor.
|
|
Query vector capacity. Note that you should rarely need to do this.
|
|
The default ArrayCompareFunction for InsertSorted().
Definition at line 338 of file array.h. Referenced by csArray< iLightingProcessData *, csRefArrayElementHandler< iLightingProcessData * > >::InsertSorted. |
|
The default ArrayCompareKeyFunction for FindKey().
Definition at line 346 of file array.h. Referenced by csArray< iLightingProcessData *, csRefArrayElementHandler< iLightingProcessData * > >::FindSortedKey. |
|
Delete the given element from vector.
|
|
Clear entire vector.
Definition at line 446 of file array.h. Referenced by csTreeNode::BSF, csArray< iLightingProcessData *, csRefArrayElementHandler< iLightingProcessData * > >::ShrinkBestFit, and csArray< iLightingProcessData *, csRefArrayElementHandler< iLightingProcessData * > >::TransferTo. |
|
Delete element number 'n' from vector.
Definition at line 517 of file array.h. Referenced by csTreeNode::BSF, csHash< K, T, ReverseKeyHandler >::Delete, csArray< iLightingProcessData *, csRefArrayElementHandler< iLightingProcessData * > >::Delete, and csHash< K, T, ReverseKeyHandler >::DeleteAll. |
|
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. Definition at line 481 of file array.h. Referenced by csHash< K, T, ReverseKeyHandler >::DeleteAll. |
|
Find a element in array and return its index (or -1 if not found).
Definition at line 413 of file array.h. Referenced by csArray< iLightingProcessData *, csRefArrayElementHandler< iLightingProcessData * > >::Delete. |
|
Find an element based on some key.
|
|
Find an element based on some key, using a csArrayCompareKeyFunction. The array must be sorted. Returns -1 if element does not exist. Reimplemented in csStringArray. |
|
Get an element (const).
|
|
Get an element (non-const).
Definition at line 229 of file array.h. Referenced by csGrid::GetRootView, and csArray< iLightingProcessData *, csRefArrayElementHandler< iLightingProcessData * > >::operator[]. |
|
Get an item from the array. If the number of elements in this array is too small the array will be automatically extended. |
|
Returns an Iterator which traverses the Array.
|
|
Initialize a region. This is a dangerous function to use because it does not properly destruct the items in the array. |
|
Insert element 'item' before element 'n'.
Definition at line 311 of file array.h. Referenced by csArray< iLightingProcessData *, csRefArrayElementHandler< iLightingProcessData * > >::InsertSorted. |
|
Insert an element at a sorted position, using a csArrayCompareFunction. Assumes array is already sorted. |
|
|
Assignment operator.
|
|
Get a const reference.
|
|
Get an element (non-const).
|
|
Pop an element from tail end of array.
Reimplemented in csPDelArray. |
|
Push an element onto the tail end of the array. Returns index of element.
Definition at line 276 of file array.h. Referenced by csAnimationTemplate::AddFrame, csPluginPaths::AddOnce, csTreeNode::BSF, csBlockAllocator< Element >::csBlockAllocator, csHash< K, T, ReverseKeyHandler >::GetAll, csHash< K, T, ReverseKeyHandler >::Put, csHash< K, T, ReverseKeyHandler >::PutFirst, and csArray< iLightingProcessData *, csRefArrayElementHandler< iLightingProcessData * > >::Section. |
|
Put an element at some position.
|
|
Get the portion of the array between low and high inclusive.
|
|
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 vector length to n.
Reimplemented in csPDelArray. |
|
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. Reimplemented in csPDelArray. Definition at line 198 of file array.h. Referenced by csHash< K, T, ReverseKeyHandler >::csHash, csHash< K, T, ReverseKeyHandler >::DeleteAll, csArray< iLightingProcessData *, csRefArrayElementHandler< iLightingProcessData * > >::GetExtend, csStaticLODFactoryMesh::GetMeshesForLOD, csStaticLODMesh::GetMeshesForLOD, and csArray< iLightingProcessData *, csRefArrayElementHandler< iLightingProcessData * > >::Put. |
|
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. |
|
Sort array.
Reimplemented in csStringArray. |
|
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 464 of file array.h. Referenced by csArray< iLightingProcessData *, csRefArrayElementHandler< iLightingProcessData * > >::Empty, and csArray< iLightingProcessData *, csRefArrayElementHandler< iLightingProcessData * > >::SetLength. |