Open Reality Reference Guide
FBArrayTemplate< Type > Class Template Reference

Template class to contain an array of items. More...

#include <fbarray.h>

Inheritance diagram for FBArrayTemplate< Type >:

Public Member Functions

 FBArrayTemplate (int pItemPerBlock=10)
 Constructor. More...
 
 FBArrayTemplate (const FBArrayTemplate< Type > &pArrayTemplate)
 Copy constructor. More...
 
 ~FBArrayTemplate ()
 Destructor. More...
 
int InsertAt (int pIndex, Type pItem)
 Insert pItem at pIndex. More...
 
void RemoveAt (int pIndex)
 Remove item at pIndex. More...
 
void RemoveLast ()
 Remove the last item in the array. More...
 
bool Remove (Type &pItem)
 Remove pItem from the array. More...
 
bool RemoveIt (Type pItem)
 Remove pItem from the array. More...
 
void Clear ()
 Empty the array of all items. More...
 
Type & operator[] (int pIndex) const
 [] operator overload. More...
 
void SetAt (int pIndex, Type pItem)
 Set item at pIndex to pItem. More...
 
void SetLast (Type pItem)
 Set the last item of the array. More...
 
int GetCount () const
 Get the number of items in the array. More...
 
void SetCount (int pCount)
 Set the number of items in the array. More...
 
Type GetAt (int pIndex)
 Get item at pIndex. More...
 
Type GetLast ()
 Get last item of the array. More...
 
int Find (Type pItem)
 Find the index of pItem in the array. More...
 
int Add (Type pItem)
 Add an item to the end of the array. More...
 
Type * GetArray ()
 Get a pointer to the array of items. More...
 
FBArrayTemplate< Type > & operator= (const FBArrayTemplate< Type > &pArrayTemplate)
 Copy array of pointers without copying the associated objects. More...
 

Detailed Description

template<class Type>
class FBArrayTemplate< Type >

Template class to contain an array of items.

Note
This utility template array only support plain old data structure (POD).

Definition at line 77 of file fbarray.h.

Constructor & Destructor Documentation

◆ FBArrayTemplate() [1/2]

FBArrayTemplate ( int  pItemPerBlock = 10)
inline

Constructor.

Parameters
pItemPerBlockNumber of items per array block (default is 10).

Definition at line 83 of file fbarray.h.

◆ FBArrayTemplate() [2/2]

FBArrayTemplate ( const FBArrayTemplate< Type > &  pArrayTemplate)
inline

Copy constructor.

Definition at line 92 of file fbarray.h.

◆ ~FBArrayTemplate()

~FBArrayTemplate ( )
inline

Destructor.

Definition at line 103 of file fbarray.h.

Member Function Documentation

◆ Add()

int Add ( Type  pItem)
inline

Add an item to the end of the array.

Parameters
pItemItem to insert into the array.
Returns
Index where pItem was inserted.

Definition at line 298 of file fbarray.h.

◆ Clear()

void Clear ( )
inline

Empty the array of all items.

Definition at line 185 of file fbarray.h.

References FBFree().

◆ Find()

int Find ( Type  pItem)
inline

Find the index of pItem in the array.

Parameters
pItemItem to look for in the array.
Returns
Index number of element found. Returns -1 if pItem was not found.

Definition at line 283 of file fbarray.h.

◆ GetArray()

Type* GetArray ( )
inline

Get a pointer to the array of items.

Returns
Pointer to the array of items.
Warning
Gives direct access to the array pointer!

Definition at line 307 of file fbarray.h.

◆ GetAt()

Type GetAt ( int  pIndex)
inline

Get item at pIndex.

Parameters
pIndexIndex of desired item.
Returns
Item specified by pIndex.

Definition at line 265 of file fbarray.h.

◆ GetCount()

int GetCount ( ) const
inline

Get the number of items in the array.

Returns
Number of items in the array.

Definition at line 227 of file fbarray.h.

Referenced by FBArrayTemplate< Type >::operator=().

◆ GetLast()

Type GetLast ( )
inline

Get last item of the array.

Returns
Last item of the array.

Definition at line 274 of file fbarray.h.

◆ InsertAt()

int InsertAt ( int  pIndex,
Type  pItem 
)
inline

Insert pItem at pIndex.

Parameters
pIndexIndex to insert at.
pItemItem to insert.
Returns
Actual insertion index where pItem was inserted.

Definition at line 113 of file fbarray.h.

References FBRealloc().

◆ operator=()

FBArrayTemplate<Type>& operator= ( const FBArrayTemplate< Type > &  pArrayTemplate)
inline

Copy array of pointers without copying the associated objects.

Parameters
pArrayTemplateArray to copy from.
Returns
Pointer to the this class.

Definition at line 316 of file fbarray.h.

References FBArrayTemplate< Type >::GetCount().

◆ operator[]()

Type& operator[] ( int  pIndex) const
inline

[] operator overload.

Parameters
pIndexIndex of item to access.
Returns
Item corresponding to pIndex.

Definition at line 199 of file fbarray.h.

◆ Remove()

bool Remove ( Type &  pItem)
inline

Remove pItem from the array.

Parameters
pItemItem to remove.
Returns
Operation was successful (true or false).

Definition at line 160 of file fbarray.h.

◆ RemoveAt()

void RemoveAt ( int  pIndex)
inline

Remove item at pIndex.

Parameters
pIndexIndex to remove item from.

Definition at line 142 of file fbarray.h.

◆ RemoveIt()

bool RemoveIt ( Type  pItem)
inline

Remove pItem from the array.

Parameters
pItemItem to remove.
Returns
Outcome of removal (true or false).

Definition at line 174 of file fbarray.h.

◆ RemoveLast()

void RemoveLast ( )
inline

Remove the last item in the array.

Definition at line 154 of file fbarray.h.

◆ SetAt()

void SetAt ( int  pIndex,
Type  pItem 
)
inline

Set item at pIndex to pItem.

Parameters
pIndexIndex of item to set.
pItemItem to copy into the array.

Definition at line 209 of file fbarray.h.

◆ SetCount()

void SetCount ( int  pCount)
inline

Set the number of items in the array.

Definition at line 234 of file fbarray.h.

References FBRealloc().

◆ SetLast()

void SetLast ( Type  pItem)
inline

Set the last item of the array.

Parameters
pItemItem to copy as the last item of the array
Warning
Will write over last item in the array!

Definition at line 219 of file fbarray.h.


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