AppEasy Core SDK
1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
|
Basic resizable slot array. More...
#include <CzSlotArray.h>
Public Member Functions | |
void | setGrowth (int growth) |
int | getSize () const |
CzSlotArray () | |
CzSlotArray (int size, int growth) | |
virtual | ~CzSlotArray () |
int | count () const |
< Gets the number of active elements, not the arrays size. | |
bool | add (T element) |
void | remove (T element) |
void | remove (int index) |
T | element_at (int index) const |
< Returns the element at the specified index. | |
bool | set (int index, T element) |
void | grow (int growth) |
void | growToSize (int new_size) |
void | resize (int size) |
int | getLastUsedSlot () const |
< Returns the last used array index | |
void | clear (bool delete_elements=false) |
void | compact () |
Protected Attributes | |
int | Growth |
Number of elements to grow array when we run out of space. | |
T * | Elements |
Array elements. | |
int | Size |
Max size of array. | |
int | LastFreedSlot |
Slot that was last freed. |
Basic resizable slot array.
A slot array differs from a normal array in that the array is not shrank and elements are not compacted when elements are removed. Instead array elements that are removed are marked with NULL. With this, the Size of the array denotes the total number of items added to the array and not the number of valid elements. To get the number of valid elements call count()
T | Generic type parameter. |
CzSlotArray< T >::CzSlotArray | ( | ) | [inline] |
CzSlotArray< T >::CzSlotArray | ( | int | size, |
int | growth | ||
) | [inline] |
growth | Constructs an array of the specified size and growth |
virtual CzSlotArray< T >::~CzSlotArray | ( | ) | [inline, virtual] |
bool CzSlotArray< T >::add | ( | T | element | ) | [inline] |
element | Finds a free slot and adds the element. If none free then the array size is grown. |
void CzSlotArray< T >::clear | ( | bool | delete_elements = false | ) | [inline] |
delete_elements | Clear the array, optionally deleting contents |
void CzSlotArray< T >::compact | ( | ) | [inline] |
int CzSlotArray< T >::count | ( | ) | const [inline] |
< Gets the number of active elements, not the arrays size.
T CzSlotArray< T >::element_at | ( | int | index | ) | const [inline] |
< Returns the element at the specified index.
int CzSlotArray< T >::getLastUsedSlot | ( | ) | const [inline] |
< Returns the last used array index
int CzSlotArray< T >::getSize | ( | ) | const [inline] |
void CzSlotArray< T >::grow | ( | int | growth | ) | [inline] |
growth | Grow the array |
void CzSlotArray< T >::growToSize | ( | int | new_size | ) | [inline] |
new_size | Grow the array to the new size |
void CzSlotArray< T >::remove | ( | T | element | ) | [inline] |
element | Removes the specified element from the array. |
void CzSlotArray< T >::remove | ( | int | index | ) | [inline] |
index | Removes the element at the specified index from the array. |
void CzSlotArray< T >::resize | ( | int | size | ) | [inline] |
size | Change the size of the array, if new size is smaller than current size then it will be shrank |
bool CzSlotArray< T >::set | ( | int | index, |
T | element | ||
) | [inline] |
element | Sets the element at the specific index. |
void CzSlotArray< T >::setGrowth | ( | int | growth | ) | [inline] |
T* CzSlotArray< T >::Elements [protected] |
Array elements.
int CzSlotArray< T >::Growth [protected] |
Number of elements to grow array when we run out of space.
int CzSlotArray< T >::LastFreedSlot [protected] |
Slot that was last freed.
int CzSlotArray< T >::Size [protected] |
Max size of array.