KBaseArray Class Template Reference

#include <karrayul.h>

List of all members.


Detailed Description

template<class TypeSize>
class KBaseArray< TypeSize >

Definition at line 139 of file karrayul.h.


Public Member Functions

int  GetCount () const
  Get number of pointers in the array.
void  Clear ()
  Remove all pointers without deleting the associated objects.
void  Empty ()
  Fast empty, set object count to zero but don't free any memory.
int  Reserve (int pCapacity)
  Set array capacity to contain at least the specified number of elements without reallocating.
void  SetCount (int pCount)
  Set arrayCount to specified number of elements. The array capacity is adjusted accordingly.
void  Resize (int pItemCount)
void  AddMultiple (int pItemCount)
int  GetTypeSize () const

Protected Member Functions

  KBaseArray (TypeSize pTypeSize)
  Constructor.
  ~KBaseArray ()
  Destructor.
int  InsertAt (int pIndex, void *pItem)
  Insert an item at the given position.
void *  GetAt (int pIndex)
  Get the item at the given position.
void  RemoveAt (int pIndex)
  Removes the item at the given position.
bool  ValidateIndex (int pIndex) const
  Check that the given position is inside the array boundaries.

Classes

struct   KHeader

Constructor & Destructor Documentation

KBaseArray ( TypeSize  pTypeSize  )  [inline, protected]

Constructor.

Parameters:
pTypeSize  Size of one item of the array.

Definition at line 152 of file karrayul.h.

~KBaseArray (  )  [inline, protected]

Destructor.

Definition at line 160 of file karrayul.h.


Member Function Documentation

int InsertAt ( int  pIndex,
void *  pItem  
) [inline, protected]

Insert an item at the given position.

Parameters:
pIndex  Position where to insert the item.
pItem  Pointer to the item to be inserted.
Remarks:
if pIndex is greater than the number of items already in the array, the item will be appended at the end.
Returns:
The actual position where the item as been inserted.

Reimplemented in KArrayTemplate< void * >.

Definition at line 171 of file karrayul.h.

void* GetAt ( int  pIndex  )  [inline, protected]

Get the item at the given position.

Parameters:
pIndex  The position of the item to access.
Returns:
Pointer to the item.
Remarks:
This method assumes that the passed index is in the valid range of the array. No checks are made.

Definition at line 217 of file karrayul.h.

void RemoveAt ( int  pIndex  )  [inline, protected]

bool ValidateIndex ( int  pIndex  )  const [inline, protected]

Check that the given position is inside the array boundaries.

Parameters:
pIndex  Index value to validate.
Returns:
true if the index value is within the array boundaries. false otherwise.

Definition at line 253 of file karrayul.h.

Referenced by KBaseArray< KBaseArraySizeType< KXRefManagerProject * > >::RemoveAt().

int GetCount (  )  const [inline]

void Clear (  )  [inline]

Remove all pointers without deleting the associated objects.

Definition at line 276 of file karrayul.h.

Referenced by KStringListTemplate< KStringListItem >::Clear(), and KBaseArray< KBaseArraySizeType< KXRefManagerProject * > >::~KBaseArray().

void Empty (  )  [inline]

Fast empty, set object count to zero but don't free any memory.

Definition at line 287 of file karrayul.h.

int Reserve ( int  pCapacity  )  [inline]

Set array capacity to contain at least the specified number of elements without reallocating.

Parameters:
pCapacity  Number of items that can be stored in the array before reallocating the memory.
Returns:
The number of available slots in the array.
Remarks:
If capacity is lower than arrayCount, arrayCount is lowered to capacity.

Definition at line 303 of file karrayul.h.

void SetCount ( int  pCount  )  [inline]

Set arrayCount to specified number of elements. The array capacity is adjusted accordingly.

Force the array of elements to a given size.

Remarks:
If the array is upsized, the memory allocated is set to 0 and no constructor is called. Thus, this function is not appropriate for types of elements requiring initialization.

Definition at line 352 of file karrayul.h.

void Resize ( int  pItemCount  )  [inline]

Definition at line 373 of file karrayul.h.

void AddMultiple ( int  pItemCount  )  [inline]

int GetTypeSize (  )  const [inline]