## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# csArray< T, ElementHandler, MemoryAllocator > Class Template Reference
[Containers]

A templated array class. More...

`#include <csutil/array.h>`

List of all members.

## Public Member Functions

size_t | Capacity () const
| Query vector capacity. Note that you should rarely need to do this.
size_t | Contains (T const &which) const
| An alias for Find() which may be considered more idiomatic by some.
| csArray (const csArray &source)
| Copy constructor.
| csArray (size_t in_capacity=0, size_t in_threshold=0)
| Initialize object to have initial capacity of `in_capacity` elements, and to increase storage by `in_threshold` each time the upper bound is exceeded.
bool | Delete (T const &item)
| Delete the given element from the array.
void | DeleteAll ()
| Clear entire array, releasing all allocated memory.
bool | DeleteFast (T const &item)
| Delete the given element from the array.
bool | DeleteIndex (size_t n)
| Delete an element from the array.
bool | DeleteIndexFast (size_t n)
| Delete an element from the array in constant-time, regardless of the array's size.
void | DeleteRange (size_t start, size_t end)
| Delete a given range (inclusive).
void | Empty ()
| Remove all elements.
size_t | Find (T const &which) const
| Find an element in array.
template<class K>
size_t | FindKey (csArrayCmp< T, K > comparekey) const
| Find an element based upon some arbitrary key, which may be embedded within an element, or otherwise derived from it.
template<class K>
size_t | FindSortedKey (csArrayCmp< T, K > comparekey, size_t *candidate=0) const
| Find an element based on some key, using a comparison function.
T const & | Get (size_t n) const
| Get an element (const).
T & | Get (size_t n)
| Get an element (non-const).
T & | GetExtend (size_t n)
| Get an item from the array.
size_t | GetIndex (const T *which) const
| Given a pointer to an element in the array this function will return the index.
Iterator | GetIterator () const
| Returns an Iterator which traverses the array.
size_t | GetSize () const
| Return the number of elements in the array.
bool | Insert (size_t n, T const &item)
| Insert element `item` before element `n`.
size_t | InsertSorted (const T &item, int(*compare)(T const &, T const &)=DefaultCompare, size_t *equal_index=0)
| Insert an element at a sorted position, using an element comparison function.
bool | IsEmpty () const
| Return true if the array is empty.
size_t | Length () const
| Return the number of elements in the array.
csArray< T, ElementHandler > & | operator= (const csArray &other)
| Assignment operator.
bool | operator== (const csArray &other) const
| Check if this array has the exact same contents as other.
T const & | operator[] (size_t n) const
| Get a const reference.
T & | operator[] (size_t n)
| Get an element (non-const).
T | Pop ()
| Pop an element from tail end of array.
size_t | Push (T const &what)
| Push a copy of an element onto the tail end of the array.
size_t | PushSmart (T const &what)
| Push a element onto the tail end of the array if not already present.
void | Put (size_t n, T const &what)
| Insert a copy of element at the indicated position.
csArray< T > | Section (size_t low, size_t high) const
| Get the portion of the array between `low` and `high` inclusive.
void | SetCapacity (size_t n)
| Set vector capacity to approximately `n` elements.
void | SetMinimalCapacity (size_t n)
| Set vector capacity to at least `n` elements.
void | SetSize (size_t n)
| Set the actual number of items in this array.
void | SetSize (size_t n, T const &what)
| Set the actual number of items in this array.
void | ShrinkBestFit ()
| Make the array just as big as it needs to be.
void | Sort (int(*compare)(T const &, T const &)=DefaultCompare)
| Sort array using a comparison function.
T & | Top ()
| Return the top element but do not remove it. (non-const).
T const & | Top () const
| Return the top element but do not remove it. (const).
void | TransferTo (csArray &destination)
| Transfer the entire contents of one array to the other.
void | Truncate (size_t n)
| Truncate array to specified number of elements.
| ~csArray ()
| Destroy array and all contained elements.
void | SetLength (size_t n)
void | SetLength (size_t n, T const &what)
| Set the actual number of items in this array.

## Static Public Member Functions

static int | DefaultCompare (T const &r1, T const &r2)
| Compare two objects of the same type.

## Protected Member Functions

void | InitRegion (size_t start, size_t count)
| Initialize a region.

## Classes

class | Iterator
| Iterator for the Array<> class. More...

## Detailed Description

### template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
class csArray< T, ElementHandler, MemoryAllocator >

A templated array class.

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 iFoo*, then you should consider csRefArray<>, which is more idiomatic than csArray<csRef<iFoo> >.

Definition at line 299 of file array.h.

## Constructor & Destructor Documentation

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
csArray< T, ElementHandler, MemoryAllocator >::csArray | ( | size_t | in_capacity = `0`,
|  | size_t | in_threshold = `0`
| ) | `[inline]`

| Initialize object to have initial capacity of `in_capacity` elements, and to increase storage by `in_threshold` each time the upper bound is exceeded. Definition at line 421 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
csArray< T, ElementHandler, MemoryAllocator >::~csArray | ( |  | ) | `[inline]`

| Destroy array and all contained elements. Definition at line 443 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
csArray< T, ElementHandler, MemoryAllocator >::csArray | ( | const csArray< T, ElementHandler, MemoryAllocator > & | source | ) | `[inline]`

| Copy constructor. Definition at line 449 of file array.h.

## Member Function Documentation

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
size_t csArray< T, ElementHandler, MemoryAllocator >::Capacity | ( |  | ) | const`[inline]`

| Query vector capacity. Note that you should rarely need to do this. Definition at line 483 of file array.h. Referenced by csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::SetMinimalCapacity().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
size_t csArray< T, ElementHandler, MemoryAllocator >::Contains | ( | T const & | which | ) | const`[inline]`

| An alias for Find() which may be considered more idiomatic by some. Definition at line 794 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
static int csArray< T, ElementHandler, MemoryAllocator >::DefaultCompare | ( | T const & | r1,
|  | T const & | r2
| ) | `[inline, static]`

Compare two objects of the same type.

Parameters:

  | r1 | Reference to first object.
  | r2 | Reference to second object.

Returns:
  Zero if the objects are equal; less-than-zero if the first object is less than the second; or greater-than-zero if the first object is greater than the second.

Remarks:
  Assumes the existence of T::operator<(T). This is the default comparison function used by csArray for sorting if the client does not provide a custom function.

Definition at line 411 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
bool csArray< T, ElementHandler, MemoryAllocator >::Delete | ( | T const & | item | ) | `[inline]`

Delete the given element from the array.

Remarks:
  Performs a linear search of the array to locate `item`, thus it may be slow for large arrays.

Definition at line 1005 of file array.h.

Referenced by csObjectModel::RemoveListener().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
void csArray< T, ElementHandler, MemoryAllocator >::DeleteAll | ( |  | ) | `[inline]`

Clear entire array, releasing all allocated memory.

Definition at line 822 of file array.h.

Referenced by csTreeNode::BSF(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::ShrinkBestFit(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::TransferTo(), and csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::~csArray().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
bool csArray< T, ElementHandler, MemoryAllocator >::DeleteFast | ( | T const & | item | ) | `[inline]`

Delete the given element from the array.

Remarks:
  This is a special version of Delete() which does not preserve the order of the remaining elements. This characteristic allows deletions to be performed somewhat more quickly than by Delete(), however the speed gain is largely mitigated by the fact that a linear search is performed in order to locate `item`, thus this optimization is mostly illusory.

Deprecated:
  The speed gain promised by this method is mostly illusory on account of the linear search for the item. In many cases, it will be faster to keep the array sorted, search for `item` using FindSortedKey(), and then remove it using the plain DeleteIndex().

Definition at line 1026 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
bool csArray< T, ElementHandler, MemoryAllocator >::DeleteIndex | ( | size_t | n | ) | `[inline]`

Delete an element from the array.

return True if the indicated item index was valid, else false.

Remarks:
  Deletion speed is proportional to the size of the array and the location of the element being deleted. If the order of the elements in the array is not important, then you can instead use DeleteIndexFast() for constant-time deletion.

Definition at line 935 of file array.h.

Referenced by csTreeNode::BSF(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::Delete(), scfStringArray::DeleteIndex(), and csTreeNode::RemoveChild().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
bool csArray< T, ElementHandler, MemoryAllocator >::DeleteIndexFast | ( | size_t | n | ) | `[inline]`

Delete an element from the array in constant-time, regardless of the array's size.

return True if the indicated item index was valid, else false.

Remarks:
  This is a special version of DeleteIndex() which does not preserve the order of the remaining elements. This characteristic allows deletions to be performed in constant-time, regardless of the size of the array.

Definition at line 960 of file array.h.

Referenced by csHash< csHandlerID, csRef< iEventHandler > >::Delete(), csHash< csHandlerID, csRef< iEventHandler > >::DeleteAll(), and csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::DeleteFast().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
void csArray< T, ElementHandler, MemoryAllocator >::DeleteRange | ( | size_t | start,
|  | size_t | end
| ) | `[inline]`

Delete a given range (inclusive).

Remarks:
  Will clamp `start` and `end` to the array limits.

Definition at line 980 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
void csArray< T, ElementHandler, MemoryAllocator >::Empty | ( |  | ) | `[inline]`

| 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 865 of file array.h. Referenced by scfStringArray::Empty().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
size_t csArray< T, ElementHandler, MemoryAllocator >::Find | ( | T const & | which | ) | const`[inline]`

Find an element in array.

Returns:
  csArrayItemNotFound if not found, else the item index.

Warning:
  Performs a slow linear search. For faster searching, sort the array and then use FindSortedKey().

Definition at line 785 of file array.h.

Referenced by csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::Contains(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::Delete(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::DeleteFast(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::PushSmart(), and csTreeNode::RemoveChild().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
template<class K>
size_t csArray< T, ElementHandler, MemoryAllocator >::FindKey | ( | csArrayCmp< T, K > | comparekey | ) | const`[inline]`

Find an element based upon some arbitrary key, which may be embedded within an element, or otherwise derived from it.

The incoming key functor defines the relationship between the key and the array's element type.

Returns:
  csArrayItemNotFound if not found, else item index.

Definition at line 621 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
template<class K>
size_t csArray< T, ElementHandler, MemoryAllocator >::FindSortedKey | ( | csArrayCmp< T, K > | comparekey,
|  | size_t * | candidate = `0`
| ) | const`[inline]`

Find an element based on some key, using a comparison function.

Returns:
  csArrayItemNotFound if not found, else the item index.

Remarks:
  The array must be sorted.

Definition at line 723 of file array.h.

Referenced by csBlockAllocator< csBSPTree >::FindBlock().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
T const& csArray< T, ElementHandler, MemoryAllocator >::Get | ( | size_t | n | ) | const`[inline]`

| Get an element (const). Definition at line 574 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
T& csArray< T, ElementHandler, MemoryAllocator >::Get | ( | size_t | n | ) | `[inline]`

| Get an element (non-const). Definition at line 567 of file array.h. Referenced by scfStringArray::Get(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::operator==(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::operator[](), and csTreeNode::~csTreeNode().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
T& csArray< T, ElementHandler, MemoryAllocator >::GetExtend | ( | size_t | n | ) | `[inline]`

| Get an item from the array. If the number of elements in this array is too small the array will be automatically extended, and the newly added objects will be created using their default (no-argument) constructor. Definition at line 585 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
size_t csArray< T, ElementHandler, MemoryAllocator >::GetIndex | ( | const T * | which | ) | const`[inline]`

| Given a pointer to an element in the array this function will return the index. Note that this function does not check if the returned index is actually valid. The caller of this function is responsible for testing if the returned index is within the bounds of the array. Definition at line 803 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
Iterator csArray< T, ElementHandler, MemoryAllocator >::GetIterator | ( |  | ) | const`[inline]`

| Returns an Iterator which traverses the array. Definition at line 1069 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
size_t csArray< T, ElementHandler, MemoryAllocator >::GetSize | ( |  | ) | const`[inline]`

| Return the number of elements in the array. Definition at line 468 of file array.h. Referenced by csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::IsEmpty(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::Length(), and csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::operator==().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
void csArray< T, ElementHandler, MemoryAllocator >::InitRegion | ( | size_t | start,
|  | size_t | count
| ) | `[inline, protected]`

| Initialize a region. This is a dangerous function to use because it does not properly destruct the items in the array. Definition at line 335 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
bool csArray< T, ElementHandler, MemoryAllocator >::Insert | ( | size_t | n,
|  | T const & | item
| ) | `[inline]`

| Insert element `item` before element `n`. Definition at line 691 of file array.h. Referenced by scfStringArray::Insert(), and csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::InsertSorted().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
size_t csArray< T, ElementHandler, MemoryAllocator >::InsertSorted | ( | const T & | item,
|  | int(*)(T const &, T const &) | compare = `DefaultCompare`,
|  | size_t * | equal_index = `0`
| ) | `[inline]`

Insert an element at a sorted position, using an element comparison function.

Returns:
  The index of the inserted item.

Remarks:
  The array must be sorted.

Definition at line 751 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
bool csArray< T, ElementHandler, MemoryAllocator >::IsEmpty | ( |  | ) | const`[inline]`

Return true if the array is empty.

Remarks:
  Rigidly equivalent to `return GetSize() == 0`, but more idiomatic.

Definition at line 875 of file array.h.

Referenced by scfStringArray::IsEmpty().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
size_t csArray< T, ElementHandler, MemoryAllocator >::Length | ( |  | ) | const`[inline]`

Return the number of elements in the array.

Deprecated:
  Use GetSize() instead.

Definition at line 477 of file array.h.

Referenced by csTreeNode::BSF(), csHash< csHandlerID, csRef< iEventHandler > >::Contains(), csGetShaderVariableFromStack(), csLightProperties::csLightProperties(), csHash< csHandlerID, csRef< iEventHandler > >::Delete(), csHash< csHandlerID, csRef< iEventHandler > >::DeleteAll(), csTreeNode::DSF(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::Find(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::FindKey(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::FindSortedKey(), csObjectModel::FireListeners(), csHash< csHandlerID, csRef< iEventHandler > >::Get(), csHash< csHandlerID, csRef< iEventHandler > >::GetAll(), csHash< csHandlerID, csRef< iEventHandler > >::GetElementPointer(), scfStringArray::GetSize(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::InsertSorted(), csTreeNode::IsLeaf(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::Push(), csHash< csHandlerID, csRef< iEventHandler > >::Put(), csHash< csHandlerID, csRef< iEventHandler > >::PutUnique(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::SetCapacity(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::SetMinimalCapacity(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::SetSize(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::Sort(), and csTreeNode::~csTreeNode().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
csArray<T,ElementHandler>& csArray< T, ElementHandler, MemoryAllocator >::operator= | ( | const csArray< T, ElementHandler, MemoryAllocator > & | other | ) | `[inline]`

| Assignment operator. Definition at line 461 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
bool csArray< T, ElementHandler, MemoryAllocator >::operator== | ( | const csArray< T, ElementHandler, MemoryAllocator > & | other | ) | const`[inline]`

| Check if this array has the exact same contents as other. Definition at line 1073 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
T const& csArray< T, ElementHandler, MemoryAllocator >::operator[] | ( | size_t | n | ) | const`[inline]`

| Get a const reference. Definition at line 599 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
T& csArray< T, ElementHandler, MemoryAllocator >::operator[] | ( | size_t | n | ) | `[inline]`

| Get an element (non-const). Definition at line 593 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
T csArray< T, ElementHandler, MemoryAllocator >::Pop | ( |  | ) | `[inline]`

Pop an element from tail end of array.

Reimplemented in csPDelArray< T >, csRefArray< T >, csStringArray, csPDelArray< csPlugin >, csPDelArray< ArchiveEntry >, csPDelArray< renderMeshListInfo >, csPDelArray< csPixmap >, csPDelArray< csPluginLoadRec >, csPDelArray< csPluginOption >, csRefArray< iImage >, csRefArray< csShaderVariable >, csRefArray< iParticle >, csRefArray< iObjectNameChangeListener >, csRefArray< iSprite2DState >, csRefArray< iObjectModelListener >, and csRefArray< iConfigFile >.

Definition at line 667 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
size_t csArray< T, ElementHandler, MemoryAllocator >::Push | ( | T const & | what | ) | `[inline]`

Push a copy of an element onto the tail end of the array.

Returns:
  Index of newly added element.

Definition at line 633 of file array.h.

Referenced by csTreeNode::AddChild(), csObjectModel::AddListener(), csTreeNode::BSF(), csTreeNode::csTreeNode(), csHash< csHandlerID, csRef< iEventHandler > >::GetAll(), scfStringArray::Push(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::PushSmart(), csHash< csHandlerID, csRef< iEventHandler > >::Put(), and csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::Section().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
size_t csArray< T, ElementHandler, MemoryAllocator >::PushSmart | ( | T const & | what | ) | `[inline]`

Push a element onto the tail end of the array if not already present.

Returns:
  Index of newly pushed element or index of already present element.

Definition at line 660 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
void csArray< T, ElementHandler, MemoryAllocator >::Put | ( | size_t | n,
|  | T const & | what
| ) | `[inline]`

| Insert a copy of element at the indicated position. Definition at line 605 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
csArray<T> csArray< T, ElementHandler, MemoryAllocator >::Section | ( | size_t | low,
|  | size_t | high
| ) | const`[inline]`

| Get the portion of the array between `low` and `high` inclusive. Definition at line 709 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
void csArray< T, ElementHandler, MemoryAllocator >::SetCapacity | ( | size_t | n | ) | `[inline]`

Set vector capacity to approximately `n` elements.

Remarks:
  Never sets the capacity to fewer than the current number of elements in the array. See Truncate() or SetSize() if you need to adjust the number of actual array elements.

Definition at line 886 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
void csArray< T, ElementHandler, MemoryAllocator >::SetLength | ( | size_t | n,
|  | T const & | what
| ) | `[inline]`

Set the actual number of items in this array.

Deprecated:
  Use SetSize() instead.

Reimplemented in csPDelArray< T >, csPDelArray< csPlugin >, csPDelArray< ArchiveEntry >, csPDelArray< renderMeshListInfo >, csPDelArray< csPixmap >, csPDelArray< csPluginLoadRec >, and csPDelArray< csPluginOption >.

Definition at line 562 of file array.h.

Referenced by csHash< csHandlerID, csRef< iEventHandler > >::DeleteAll().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
void csArray< T, ElementHandler, MemoryAllocator >::SetMinimalCapacity | ( | size_t | n | ) | `[inline]`

Set vector capacity to at least `n` elements.

Remarks:
  Never sets the capacity to fewer than the current number of elements in the array. See Truncate() or SetSize() if you need to adjust the number of actual array elements. This function will also never shrink the current capacity.

Definition at line 899 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
void csArray< T, ElementHandler, MemoryAllocator >::SetSize | ( | size_t | n | ) | `[inline]`

Set the actual number of items in this array.

This can be used to shrink an array (like Truncate()) or to enlarge an array, in which case it will properly construct all new items using their default (zero-argument) constructor.

Parameters:

  | n | New array length.

Definition at line 543 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
void csArray< T, ElementHandler, MemoryAllocator >::SetSize | ( | size_t | n,
|  | T const & | what
| ) | `[inline]`

Set the actual number of items in this array.

This can be used to shrink an array (like Truncate()) or to enlarge an array, in which case it will properly construct all new items based on the given item.

Parameters:

  | n | New array length.
  | what | Object used as template to construct each newly added object using the object's copy constructor when the array size is increased by this method.

Definition at line 521 of file array.h.

Referenced by csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::GetExtend(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::Put(), and csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::SetLength().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
void csArray< T, ElementHandler, MemoryAllocator >::ShrinkBestFit | ( |  | ) | `[inline]`

| Make the array just as big as it needs to be. This is useful in cases where you know the array is not going to be modified anymore in order to preserve memory. Definition at line 911 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
void csArray< T, ElementHandler, MemoryAllocator >::Sort | ( | int(*)(T const &, T const &) | compare = `DefaultCompare` | ) | `[inline]`

| Sort array using a comparison function. Reimplemented in csStringArray. Definition at line 813 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
T& csArray< T, ElementHandler, MemoryAllocator >::Top | ( |  | ) | `[inline]`

| Return the top element but do not remove it. (non-const). Definition at line 684 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
T const& csArray< T, ElementHandler, MemoryAllocator >::Top | ( |  | ) | const`[inline]`

| Return the top element but do not remove it. (const). Definition at line 677 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
void csArray< T, ElementHandler, MemoryAllocator >::TransferTo | ( | csArray< T, ElementHandler, MemoryAllocator > & | destination | ) | `[inline]`

| 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. Definition at line 494 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
void csArray< T, ElementHandler, MemoryAllocator >::Truncate | ( | size_t | n | ) | `[inline]`

Truncate array to specified number of elements.

The new number of elements cannot exceed the current number of elements.

Remarks:
  Does not reclaim memory used by the array itself, though the removed objects are destroyed. To reclaim the array's memory invoke ShrinkBestFit(), or DeleteAll() if you want to release all allocated resources.

  The more general-purpose SetSize() method can also enlarge the array.

Definition at line 849 of file array.h.

Referenced by csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::Empty(), and csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::SetSize().

The documentation for this class was generated from the following file:

- csutil/array.h