![]() |
Public API Reference |
![]() |
Array interface template, completely changeable. More...
#include <iutil/array.h>
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, T const &what)=0 |
Set the actual number of items in this array. | |
virtual void | SetSize (size_t n)=0 |
Set the actual number of items in this array. | |
virtual void | Truncate (size_t n)=0 |
Truncate array to specified number of elements. |
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.
virtual bool iArrayChangeAll< T >::Delete | ( | T const & | item | ) | [pure virtual] |
Delete the given element from the array.
item
, thus it may be slow for large arrays. virtual void iArrayChangeAll< T >::DeleteAll | ( | ) | [pure virtual] |
Clear entire array, releasing all allocated memory.
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.
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.
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.
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.
virtual bool iArrayChangeAll< T >::Insert | ( | size_t | n, |
T const & | item | ||
) | [pure virtual] |
Insert element item
before element n
.
virtual T iArrayChangeAll< T >::Pop | ( | ) | [pure virtual] |
Pop an element from tail end of array.
virtual size_t iArrayChangeAll< T >::Push | ( | T const & | what | ) | [pure virtual] |
Push a copy of an element onto the tail end of the array.
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.
virtual void iArrayChangeAll< T >::Put | ( | size_t | n, |
T const & | what | ||
) | [pure virtual] |
Insert a copy of element at the indicated position.
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.
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. |
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.
n | New array length. |
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.