CrystalSpace

Public API Reference

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

A templated array class. More...

#include <csutil/array.h>

Inheritance diagram for csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >:

Inheritance graph
[legend]

List of all members.

Public Types

typedef MemoryAllocator AllocatorType
typedef CapacityHandler CapacityHandlerType
typedef ElementHandler ElementHandlerType
typedef csArray< T,
ElementHandler,
MemoryAllocator,
CapacityHandler > 
ThisType
typedef T ValueType

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, const MemoryAllocator &alloc, const CapacityHandler &ch)
 Initialize object to have initial capacity of in_capacity elements and with specific memory allocator and capacity handler initializations.
 csArray (size_t in_capacity=0, const CapacityHandler &ch=CapacityHandler())
 Initialize object to have initial capacity of in_capacity elements.
bool Delete (T const &item)
 Delete the given element from the array.
void DeleteAll ()
 Clear entire array, releasing all allocated memory.
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.
bool 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).
const MemoryAllocator & GetAllocator () const
 Return a reference to the allocator of this array.
T & GetExtend (size_t n, T const &what)
 Get an item from the array.
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.
ConstIterator GetIterator () const
 Returns an Iterator which traverses the array.
Iterator GetIterator ()
 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.
bool operator!= (const csArray &other) const
csArray< T,
ElementHandler,
MemoryAllocator,
CapacityHandler > & 
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).
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.
void SetData (T *data)
 Set the internal pointer to the data.

Classes

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


Detailed Description

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
class csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >

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 351 of file array.h.


Constructor & Destructor Documentation

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::csArray ( size_t  in_capacity = 0,
const CapacityHandler &  ch = CapacityHandler() 
) [inline]

Initialize object to have initial capacity of in_capacity elements.

The storage increase depends on the specified capacity handler. The default capacity handler accepts a threshold parameter by which the storage is increased each time the upper bound is exceeded.

Definition at line 469 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::csArray ( size_t  in_capacity,
const MemoryAllocator &  alloc,
const CapacityHandler &  ch 
) [inline]

Initialize object to have initial capacity of in_capacity elements and with specific memory allocator and capacity handler initializations.

Definition at line 489 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::~csArray (  )  [inline]

Destroy array and all contained elements.

Definition at line 508 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::csArray ( const csArray< T, ElementHandler, MemoryAllocator, CapacityHandler > &  source  )  [inline]

Copy constructor.

Definition at line 514 of file array.h.


Member Function Documentation

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
size_t csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::Capacity (  )  const [inline]

Query vector capacity. Note that you should rarely need to do this.

Definition at line 541 of file array.h.

Referenced by csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::SetMinimalCapacity().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
size_t csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::Contains ( T const &  which  )  const [inline]

An alias for Find() which may be considered more idiomatic by some.

Definition at line 858 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
static int csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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 458 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
bool csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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 1065 of file array.h.

Referenced by csFIFO< T, ElementHandler, MemoryAllocator >::Delete().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
void csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::DeleteAll (  )  [inline]

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
bool csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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 993 of file array.h.

Referenced by csTreeNode::BSF(), csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::Delete(), scfStringArray::DeleteIndex(), csTreeNode::RemoveChild(), and CS::Utility::WeakReferenced::RemoveRefOwner().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
bool csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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 1018 of file array.h.

Referenced by csHash< csEventCord *, csStringID >::Delete(), and csHash< csEventCord *, csStringID >::DeleteAll().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
bool csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::DeleteRange ( size_t  start,
size_t  end 
) [inline]

Delete a given range (inclusive).

Remarks:
Will clamp start and end to the array limits.
Returns:
false in case the inputs were invalid (csArrayItemNotFound) or if the start is greater then the number of items in the array.

Definition at line 1040 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
void csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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 926 of file array.h.

Referenced by scfStringArray::Empty(), and csFIFO< T, ElementHandler, MemoryAllocator >::PopTop().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
size_t csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::Find ( T const &  which  )  const [inline]

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
template<class K>
size_t csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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 679 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
template<class K>
size_t csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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 781 of file array.h.

Referenced by CS::Utility::WeakReferenced::RemoveRefOwner().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
T const& csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::Get ( size_t  n  )  const [inline]

Get an element (const).

Definition at line 620 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
T& csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::Get ( size_t  n  )  [inline]

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
const MemoryAllocator& csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::GetAllocator (  )  const [inline]

Return a reference to the allocator of this array.

Definition at line 1161 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
T& csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::GetExtend ( size_t  n,
T const &  what 
) [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 constructed based on the given item what.

Definition at line 643 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
T& csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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 631 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
size_t csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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 867 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
ConstIterator csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::GetIterator (  )  const [inline]

Returns an Iterator which traverses the array.

Definition at line 1146 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
Iterator csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::GetIterator (  )  [inline]

Returns an Iterator which traverses the array.

Definition at line 1142 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
size_t csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::GetSize (  )  const [inline]

Return the number of elements in the array.

Definition at line 535 of file array.h.

Referenced by csTreeNode::BSF(), csHash< csEventCord *, csStringID >::Contains(), csGetShaderVariableFromStack(), csHash< csEventCord *, csStringID >::Delete(), csHash< csEventCord *, csStringID >::DeleteAll(), csTreeNode::DSF(), csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::Find(), csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::FindKey(), csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::FindSortedKey(), csHash< csEventCord *, csStringID >::Get(), csHash< csEventCord *, csStringID >::GetAll(), csDirtyAccessArray< uint32 >::GetArrayCopy(), csHash< csEventCord *, csStringID >::GetElementPointer(), scfStringArray::GetSize(), csFIFO< T, ElementHandler, MemoryAllocator >::GetSize(), csFrameDataHolder< csParticleSystem::PerFrameData >::GetUnusedData(), csHash< T, K, ArrayMemoryAlloc >::ConstGlobalIterator::HasNext(), csHash< T, K, ArrayMemoryAlloc >::GlobalIterator::HasNext(), csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::InsertSorted(), csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::IsEmpty(), csTreeNode::IsLeaf(), csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::Length(), csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::operator==(), csFIFO< T, ElementHandler, MemoryAllocator >::PopTop(), csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::Push(), csHash< csEventCord *, csStringID >::Put(), csHash< csEventCord *, csStringID >::PutUnique(), csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::SetCapacity(), csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::SetMinimalCapacity(), csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::SetSize(), csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::Sort(), csTreeNode::~csTreeNode(), and CS::Utility::WeakReferenced::~WeakReferenced().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
void csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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 387 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
bool csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::Insert ( size_t  n,
T const &  item 
) [inline]

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
size_t csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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.

Parameters:
item The item to insert.
compare [optional] Pointer to a function to compare two elements.
equal_index [optional] Returns the index of an element equal to the one to be inserted, if one is found. csArrayItemNotFound otherwise.
Returns:
The index of the inserted item.
Remarks:
The array must be sorted.

Definition at line 815 of file array.h.

Referenced by CS::Utility::WeakReferenced::AddRefOwner().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
bool csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::IsEmpty (  )  const [inline]

Return true if the array is empty.

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

Definition at line 936 of file array.h.

Referenced by scfStringArray::IsEmpty().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
size_t csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::Length (  )  const [inline]

Return the number of elements in the array.

Deprecated:
Use GetSize() instead.

Definition at line 1171 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
csArray<T,ElementHandler,MemoryAllocator,CapacityHandler>& csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::operator= ( const csArray< T, ElementHandler, MemoryAllocator, CapacityHandler > &  other  )  [inline]

Assignment operator.

Definition at line 523 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
bool csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::operator== ( const csArray< T, ElementHandler, MemoryAllocator, CapacityHandler > &  other  )  const [inline]

Check if this array has the exact same contents as other.

Definition at line 1150 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
T const& csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::operator[] ( size_t  n  )  const [inline]

Get a const reference.

Definition at line 657 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
T& csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::operator[] ( size_t  n  )  [inline]

Get an element (non-const).

Definition at line 651 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
T csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::Pop (  )  [inline]

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
size_t csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::Push ( T const &  what  )  [inline]

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
size_t csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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 718 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
void csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::Put ( size_t  n,
T const &  what 
) [inline]

Insert a copy of element at the indicated position.

Definition at line 663 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
csArray<T> csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::Section ( size_t  low,
size_t  high 
) const [inline]

Get the portion of the array between low and high inclusive.

Definition at line 767 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
void csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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 947 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
void csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::SetData ( T *  data  )  [inline, protected]

Set the internal pointer to the data.

Warning:
This is obviously dangerous.

Definition at line 396 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
void csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::SetLength ( size_t  n,
T const &  what 
) [inline]

Set the actual number of items in this array.

Deprecated:
Use SetSize() instead.

Definition at line 1182 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
void csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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 960 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
void csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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.

Reimplemented in csPDelArray< T >, csPDelArray< csPluginManager::csPlugin >, csPDelArray< csPixmap >, csPDelArray< csPluginLoadRec >, csPDelArray< csArchive::ArchiveEntry >, csPDelArray< csPluginManager::csPluginOption >, and csPDelArray< csRenderMeshList::renderMeshListInfo >.

Definition at line 597 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
void csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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 575 of file array.h.

Referenced by csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::GetExtend(), csFrameDataHolder< csParticleSystem::PerFrameData >::GetUnusedData(), csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::Put(), and csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::SetLength().

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
void csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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 972 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
void csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::Sort ( int(*)(T const &, T const &)  compare = DefaultCompare  )  [inline]

Sort array using a comparison function.

Reimplemented in csStringArray.

Definition at line 877 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
T& csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::Top (  )  [inline]

Return the top element but do not remove it. (non-const).

Definition at line 742 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
T const& csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::Top (  )  const [inline]

Return the top element but do not remove it. (const).

Definition at line 735 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
void csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::TransferTo ( csArray< T, ElementHandler, MemoryAllocator, CapacityHandler > &  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 553 of file array.h.

template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = CS::Memory::AllocatorMalloc, class CapacityHandler = csArrayCapacityDefault>
void csArray< T, ElementHandler, MemoryAllocator, CapacityHandler >::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 910 of file array.h.

Referenced by csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::Empty(), and csArray< iEventHandler *, csRefArrayElementHandler< iEventHandler * >, CS::Memory::AllocatorMalloc >::SetSize().


The documentation for this class was generated from the following file:
Generated for Crystal Space 1.2.1 by doxygen 1.5.3