KArrayTemplate Class Template Reference

#include <karrayul.h>

Inherits KBaseArray.

Inheritance diagram for KArrayTemplate:

Inheritance graph
List of all members.

Detailed Description

template<class Type>
class KArrayTemplate< Type >

Array of pointers.

Definition at line 224 of file karrayul.h.

Public Member Functions

 KArrayTemplate (int pItemPerBlock=16)
 Constructor.
 KArrayTemplate (const KArrayTemplate< Type > &pArrayTemplate)
 Copy constructor.
 ~KArrayTemplate ()
int InsertAt (int pIndex, Type pItem)
 Insert a pointer.
Type RemoveAt (int pIndex)
 Remove a pointer in the array without deleting the associated object.
Type RemoveLast ()
 Remove last pointer in the array without deleting the associated object.
bool RemoveIt (Type pItem)
 Remove first matching pointer in the array without deleting the associated object.
Type & operator[] (int pIndex) const
 Access pointer at given index.
void SetAt (int pIndex, Type pItem)
 Set pointer at given index, must within valid range.
void SetLast (Type pItem)
 Set last pointer, the array must contain at least one pointer.
Type GetAt (int pIndex) const
 Get pointer at given index, must be within valid range.
Type GetFirst () const
 Get first pointer, the array must contain at least one pointer.
Type GetLast () const
 Get last pointer, the array must contain at least one pointer.
int Find (Type pItem) const
 Find first matching pointer.
int FindAfter (int pAfterIndex, Type pItem) const
 Find first matching pointer after given index.
int FindBefore (int pBeforeIndex, Type pItem) const
 Find first matching pointer before given index.
int Add (Type pItem)
 Append a pointer at the end of the array.
int AddUnique (Type pItem)
 Add Element at the end of array if not present.
void AddMultiple (kUInt pItemCount)
 Add multiple (init to zero) elements in the array, use SetAt or GetArray to set the value of the new elements.
void AddArray (KArrayTemplate< Type > &pArray)
void AddArrayNoDuplicate (KArrayTemplate< Type > &pArray)
void RemoveArray (KArrayTemplate< Type > &pArray)
Type * GetArray ()
 Get pointer to internal array of pointers.
KArrayTemplate< Type > & operator= (const KArrayTemplate< Type > &pArrayTemplate)
 Copy array of pointers without copying the associated objects.

Public Attributes

Type *& mArray


Constructor & Destructor Documentation

KArrayTemplate ( int  pItemPerBlock = 16  )  [inline]

Constructor.

Parameters:
pItemPerBlock Number of pointers per allocated block.

Definition at line 233 of file karrayul.h.

KArrayTemplate ( const KArrayTemplate< Type > &  pArrayTemplate  )  [inline]

Copy constructor.

Definition at line 239 of file karrayul.h.


Member Function Documentation

int InsertAt ( int  pIndex,
Type  pItem 
) [inline]

Insert a pointer.

Parameters:
pIndex Position where to insert the pointer.
pItem Item to insert.
Returns:
Position of the inserted pointer in the array.
Remarks:
If the given index is out of range, the pointer is appended at the end.

Definition at line 253 of file karrayul.h.

Referenced by KArrayTemplate< KString * >::Add(), KStringListTemplate< KStringListItem >::InsertAt(), and KStringListTemplate< KStringListItem >::InsertItemAt().

Type RemoveAt ( int  pIndex  )  [inline]

Remove a pointer in the array without deleting the associated object.

Parameters:
pIndex Position of the item to remove.
Returns:
Removed item.

Reimplemented from KBaseArray.

Definition at line 262 of file karrayul.h.

Referenced by KStringListTemplate< KStringListItem >::RemoveAt(), KArrayTemplate< KString * >::RemoveIt(), and KArrayTemplate< KString * >::RemoveLast().

Type RemoveLast (  )  [inline]

Remove last pointer in the array without deleting the associated object.

Returns:
Remove item.

Definition at line 272 of file karrayul.h.

bool RemoveIt ( Type  pItem  )  [inline]

Remove first matching pointer in the array without deleting the associated object.

Parameters:
pItem Item to remove.
Returns:
true if a matching pointer is found and removed, false otherwise.

Definition at line 281 of file karrayul.h.

Referenced by KArrayTemplate< KString * >::RemoveArray().

Type& operator[] ( int  pIndex  )  const [inline]

Access pointer at given index.

Definition at line 293 of file karrayul.h.

void SetAt ( int  pIndex,
Type  pItem 
) [inline]

Set pointer at given index, must within valid range.

Definition at line 305 of file karrayul.h.

Referenced by KArrayTemplate< KString * >::AddArray(), and KArrayTemplate< KString * >::SetLast().

void SetLast ( Type  pItem  )  [inline]

Set last pointer, the array must contain at least one pointer.

Definition at line 317 of file karrayul.h.

Type GetAt ( int  pIndex  )  const [inline]

Type GetFirst (  )  const [inline]

Get first pointer, the array must contain at least one pointer.

Returns:
First pointer.

Definition at line 337 of file karrayul.h.

Type GetLast (  )  const [inline]

Get last pointer, the array must contain at least one pointer.

Returns:
Last pointer.

Definition at line 348 of file karrayul.h.

int Find ( Type  pItem  )  const [inline]

Find first matching pointer.

Returns:
Index of first matching pointer found or -1 if there is no matching element.

Definition at line 360 of file karrayul.h.

Referenced by KArrayTemplate< KString * >::AddArrayNoDuplicate(), KArrayTemplate< KString * >::AddUnique(), KStringListTemplate< KStringListItem >::FindItem(), and KArrayTemplate< KString * >::RemoveIt().

int FindAfter ( int  pAfterIndex,
Type  pItem 
) const [inline]

Find first matching pointer after given index.

Returns:
Index of first matching pointer found after given index or -1 if there is no matching pointer.
Remarks:
The index must be within valid range.

Definition at line 370 of file karrayul.h.

Referenced by KArrayTemplate< KString * >::Find().

int FindBefore ( int  pBeforeIndex,
Type  pItem 
) const [inline]

Find first matching pointer before given index.

Returns:
Index of first matching pointer found after given index or -1 if there is no matching pointer.
Remarks:
The index must be within valid range.

Definition at line 397 of file karrayul.h.

int Add ( Type  pItem  )  [inline]

Append a pointer at the end of the array.

Returns:
Index of appended pointer.

Definition at line 422 of file karrayul.h.

Referenced by KArrayTemplate< KString * >::AddArrayNoDuplicate(), KStringListTemplate< KStringListItem >::AddItem(), KArrayTemplate< KString * >::AddUnique(), and KArrayTemplate< KString * >::operator=().

int AddUnique ( Type  pItem  )  [inline]

Add Element at the end of array if not present.

Returns:
Index of Element.

Definition at line 430 of file karrayul.h.

void AddMultiple ( kUInt  pItemCount  )  [inline]

Add multiple (init to zero) elements in the array, use SetAt or GetArray to set the value of the new elements.

Parameters:
pItemCount. How many new Array elements you want.

Definition at line 443 of file karrayul.h.

Referenced by KArrayTemplate< KString * >::AddArray().

Type* GetArray (  )  [inline]

KArrayTemplate<Type>& operator= ( const KArrayTemplate< Type > &  pArrayTemplate  )  [inline]

Copy array of pointers without copying the associated objects.

Definition at line 488 of file karrayul.h.