CrystalSpace

Public API Reference

iArrayChangeAll< T > Struct Template Reference
[Containers]

Array interface template, completely changeable. More...

#include <iutil/array.h>

Inheritance diagram for iArrayChangeAll< T >:

List of all members.

Public Member Functions

virtual bool Delete (T const &item)=0
 Delete the given element from the array.
virtual void DeleteAll ()=0
 Clear entire array, releasing all allocated memory.
virtual bool DeleteIndex (size_t n)=0
 Delete an element from the array.
virtual bool DeleteIndexFast (size_t n)=0
 Delete an element from the array in constant-time, regardless of the array's size.
virtual void Empty ()=0
 Remove all elements.
virtual T & GetExtend (size_t n)=0
 Get an item from the array.
virtual bool Insert (size_t n, T const &item)=0
 Insert element item before element n.
virtual T Pop ()=0
 Pop an element from tail end of array.
virtual size_t Push (T const &what)=0
 Push a copy of an element onto the tail end of the array.
virtual size_t PushSmart (T const &what)=0
 Push a element onto the tail end of the array if not already present.
virtual void Put (size_t n, T const &what)=0
 Insert a copy of element at the indicated position.
virtual void SetSize (size_t n)=0
 Set the actual number of items in this array.
virtual void SetSize (size_t n, T const &what)=0
 Set the actual number of items in this array.
virtual void Truncate (size_t n)=0
 Truncate array to specified number of elements.

Detailed Description

template<typename T>
struct iArrayChangeAll< T >

Array interface template, completely changeable.

Extents iArrayChangeElements to also support adding new elements and removing existing elements.

This template can't be used as-is in another interface; rather, it must be derived and specialized before it can be used. Example:

 struct csBaz { ... };
 struct iBazArray : public iArrayChangeAll<csBaz>
 {
   SCF_IARRAYCHANGEALL_INTERFACE(iBarArray);
 };

Standard implementations for this interface are scfArray and scfArrayWrap.

Definition at line 151 of file array.h.


Member Function Documentation

template<typename T>
virtual bool iArrayChangeAll< T >::Delete ( T const &  item  )  [pure virtual]

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.
template<typename T>
virtual void iArrayChangeAll< T >::DeleteAll (  )  [pure virtual]

Clear entire array, releasing all allocated memory.

template<typename T>
virtual bool iArrayChangeAll< T >::DeleteIndex ( size_t  n  )  [pure virtual]

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.
template<typename T>
virtual bool iArrayChangeAll< T >::DeleteIndexFast ( size_t  n  )  [pure virtual]

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.
template<typename T>
virtual void iArrayChangeAll< T >::Empty (  )  [pure virtual]

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.

template<typename T>
virtual T& iArrayChangeAll< T >::GetExtend ( size_t  n  )  [pure virtual]

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.

template<typename T>
virtual bool iArrayChangeAll< T >::Insert ( size_t  n,
T const &  item 
) [pure virtual]

Insert element item before element n.

template<typename T>
virtual T iArrayChangeAll< T >::Pop (  )  [pure virtual]

Pop an element from tail end of array.

template<typename T>
virtual size_t iArrayChangeAll< T >::Push ( T const &  what  )  [pure virtual]

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

Returns:
Index of newly added element.
template<typename T>
virtual size_t iArrayChangeAll< T >::PushSmart ( T const &  what  )  [pure virtual]

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.
template<typename T>
virtual void iArrayChangeAll< T >::Put ( size_t  n,
T const &  what 
) [pure virtual]

Insert a copy of element at the indicated position.

template<typename T>
virtual void iArrayChangeAll< T >::SetSize ( size_t  n  )  [pure virtual]

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.
template<typename T>
virtual void iArrayChangeAll< T >::SetSize ( size_t  n,
T const &  what 
) [pure virtual]

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.
template<typename T>
virtual void iArrayChangeAll< T >::Truncate ( size_t  n  )  [pure virtual]

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.

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

Generated for Crystal Space 1.4.1 by doxygen 1.7.1