AppEasy Core SDK  1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
CzSlotArray< T > Class Template Reference

Basic resizable slot array. More...

#include <CzSlotArray.h>

List of all members.

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)
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.

Detailed Description

template<class T>
class CzSlotArray< T >

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()

Template Parameters:
TGeneric type parameter.

Constructor & Destructor Documentation

template<class T>
CzSlotArray< T >::CzSlotArray ( ) [inline]
template<class T>
CzSlotArray< T >::CzSlotArray ( int  size,
int  growth 
) [inline]
Parameters:
growthConstructs an array of the specified size and growth
template<class T>
virtual CzSlotArray< T >::~CzSlotArray ( ) [inline, virtual]

Member Function Documentation

template<class T>
bool CzSlotArray< T >::add ( element) [inline]
Parameters:
elementFinds a free slot and adds the element. If none free then the array size is grown.
template<class T>
void CzSlotArray< T >::clear ( bool  delete_elements = false) [inline]
Parameters:
delete_elementsClear the array, optionally deleting contents
template<class T>
void CzSlotArray< T >::compact ( ) [inline]
template<class T>
int CzSlotArray< T >::count ( ) const [inline]

< Gets the number of active elements, not the arrays size.

template<class T>
T CzSlotArray< T >::element_at ( int  index) const [inline]

< Returns the element at the specified index.

template<class T>
int CzSlotArray< T >::getLastUsedSlot ( ) const [inline]

< Returns the last used array index

template<class T>
int CzSlotArray< T >::getSize ( ) const [inline]
template<class T>
void CzSlotArray< T >::grow ( int  growth) [inline]
Parameters:
growthGrow the array
template<class T>
void CzSlotArray< T >::growToSize ( int  new_size) [inline]
Parameters:
new_sizeGrow the array to the new size
template<class T>
void CzSlotArray< T >::remove ( element) [inline]
Parameters:
elementRemoves the specified element from the array.
template<class T>
void CzSlotArray< T >::remove ( int  index) [inline]
Parameters:
indexRemoves the element at the specified index from the array.
template<class T>
void CzSlotArray< T >::resize ( int  size) [inline]
Parameters:
sizeChange the size of the array, if new size is smaller than current size then it will be shrank
template<class T>
bool CzSlotArray< T >::set ( int  index,
element 
) [inline]
Parameters:
elementSets the element at the specific index.
template<class T>
void CzSlotArray< T >::setGrowth ( int  growth) [inline]

Member Data Documentation

template<class T>
T* CzSlotArray< T >::Elements [protected]

Array elements.

template<class T>
int CzSlotArray< T >::Growth [protected]

Number of elements to grow array when we run out of space.

template<class T>
int CzSlotArray< T >::LastFreedSlot [protected]

Slot that was last freed.

template<class T>
int CzSlotArray< T >::Size [protected]

Max size of array.


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