CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

csPDelArray Class Template Reference

An array of pointers. More...

#include <parray.h>

List of all members.

Public Methods

 csPDelArray (int ilimit=0, int ithreshold=0)
 Initialize object to hold initially 'ilimit' elements, and increase storage by 'ithreshold' each time the upper bound is exceeded. More...

void DeleteAll ()
 Clear entire vector. More...

 ~csPDelArray ()
 Destroy the container. More...

void TransferTo (csPDelArray< T > &destination)
 Transfer the entire contents of one array to the other. More...

void SetLength (int n)
 Set vector length to n. More...

int Length () const
 Query vector length. More...

int Limit () const
 Query vector limit. More...

T * Get (int n) const
 Get a pointer. More...

T * operator[] (int n) const
 Get a pointer. More...

void Put (int n, T *ptr)
 Put a pointer. More...

int Find (T *which) const
 Find a element in array and return its index (or -1 if not found). More...

int Push (T *what)
 Push a element on 'top' of vector. More...

int PushSmart (T *what)
 Push a element on 'top' of vector if it is not already there. More...

T * Pop ()
 Pop an element from vector 'top'. More...

T * Top () const
 Return the top element but don't remove it. More...

T * GetAndClear (int n)
 Get and clear the element 'n' from vector. More...

T * Extract (int n)
 Extract element number 'n' from vector. More...

bool Delete (int n)
 Delete element number 'n' from vector. More...

bool Delete (T *item)
 Delete the given element from vector. More...

bool Insert (int n, T *item)
 Insert element 'Item' before element 'n'. More...

int FindSortedKey (void *key, csArrayCompareKeyFunction *comparekey) const
 Find an element based on some key. More...

int InsertSorted (T *item, csArrayCompareFunction *compare)
 Insert an element at a sorted position. More...


Detailed Description

template<class T>
class csPDelArray< T >

An array of pointers.

No ref counting is done on the elements in this array. Use csRefArray if you want ref counting to happen. Note that in many cases you probably want to use csRefArray instead of csPArray. This array will delete elements (using 'delete') as needed. This array properly initializes new elements in the array to NULL.

Definition at line 292 of file parray.h.


Constructor & Destructor Documentation

template<class T>
csPDelArray< T >::csPDelArray int    ilimit = 0,
int    ithreshold = 0
[inline]
 

Initialize object to hold initially 'ilimit' elements, and increase storage by 'ithreshold' each time the upper bound is exceeded.

Definition at line 303 of file parray.h.

template<class T>
csPDelArray< T >::~csPDelArray   [inline]
 

Destroy the container.

Definition at line 333 of file parray.h.


Member Function Documentation

template<class T>
bool csPDelArray< T >::Delete T *    item [inline]
 

Delete the given element from vector.

Definition at line 518 of file parray.h.

template<class T>
bool csPDelArray< T >::Delete int    n [inline]
 

Delete element number 'n' from vector.

Definition at line 503 of file parray.h.

Referenced by csPDelArray< csPluginOption >::Delete.

template<class T>
void csPDelArray< T >::DeleteAll   [inline]
 

Clear entire vector.

Definition at line 317 of file parray.h.

Referenced by csPDelArray< csPluginOption >::SetLength, csPDelArray< csPluginOption >::TransferTo, and csPDelArray< csPluginOption >::~csPDelArray.

template<class T>
T* csPDelArray< T >::Extract int    n [inline]
 

Extract element number 'n' from vector.

The element is deleted from the array and returned. You are responsible for deleting the pointer later.

Definition at line 484 of file parray.h.

Referenced by csPDelArray< csPluginOption >::Delete.

template<class T>
int csPDelArray< T >::Find T *    which const [inline]
 

Find a element in array and return its index (or -1 if not found).

Definition at line 424 of file parray.h.

Referenced by csPDelArray< csPluginOption >::Delete, and csPDelArray< csPluginOption >::PushSmart.

template<class T>
int csPDelArray< T >::FindSortedKey void *    key,
csArrayCompareKeyFunction *    comparekey
const [inline]
 

Find an element based on some key.

Definition at line 546 of file parray.h.

template<class T>
T* csPDelArray< T >::Get int    n const [inline]
 

Get a pointer.

Definition at line 400 of file parray.h.

Referenced by csAnimationTemplate::GetFrame.

template<class T>
T* csPDelArray< T >::GetAndClear int    n [inline]
 

Get and clear the element 'n' from vector.

This spot in the array will be set to NULL. You are responsible for deleting the returned pointer later.

Definition at line 471 of file parray.h.

template<class T>
bool csPDelArray< T >::Insert int    n,
T *    item
[inline]
 

Insert element 'Item' before element 'n'.

Definition at line 526 of file parray.h.

Referenced by csPDelArray< csPluginOption >::InsertSorted.

template<class T>
int csPDelArray< T >::InsertSorted T *    item,
csArrayCompareFunction *    compare
[inline]
 

Insert an element at a sorted position.

Assumes array is already sorted.

Definition at line 568 of file parray.h.

template<class T>
int csPDelArray< T >::Length   const [inline]
 

Query vector length.

Definition at line 388 of file parray.h.

Referenced by csObjectPool::Alloc, csPDelArray< csPluginOption >::Find, csPDelArray< csPluginOption >::FindSortedKey, csAnimationTemplate::GetFrameCount, and csPDelArray< csPluginOption >::InsertSorted.

template<class T>
int csPDelArray< T >::Limit   const [inline]
 

Query vector limit.

Definition at line 394 of file parray.h.

template<class T>
T* csPDelArray< T >::operator[] int    n const [inline]
 

Get a pointer.

Definition at line 407 of file parray.h.

template<class T>
T* csPDelArray< T >::Pop   [inline]
 

Pop an element from vector 'top'.

You are responsible for deleting the object later.

Definition at line 452 of file parray.h.

Referenced by csObjectPool::Alloc.

template<class T>
int csPDelArray< T >::Push T *    what [inline]
 

Push a element on 'top' of vector.

Definition at line 434 of file parray.h.

Referenced by csAnimationTemplate::AddFrame, csObjectPool::Free, and csPDelArray< csPluginOption >::PushSmart.

template<class T>
int csPDelArray< T >::PushSmart T *    what [inline]
 

Push a element on 'top' of vector if it is not already there.

Definition at line 442 of file parray.h.

template<class T>
void csPDelArray< T >::Put int    n,
T *    ptr
[inline]
 

Put a pointer.

Definition at line 414 of file parray.h.

template<class T>
void csPDelArray< T >::SetLength int    n [inline]
 

Set vector length to n.

Definition at line 356 of file parray.h.

Referenced by csPDelArray< csPluginOption >::Extract, csPDelArray< csPluginOption >::Insert, csPDelArray< csPluginOption >::Pop, csPDelArray< csPluginOption >::Push, and csPDelArray< csPluginOption >::Put.

template<class T>
T* csPDelArray< T >::Top   const [inline]
 

Return the top element but don't remove it.

Definition at line 461 of file parray.h.

template<class T>
void csPDelArray< T >::TransferTo csPDelArray< T > &    destination [inline]
 

Transfer the entire contents of one array to the other.

The end result will be that this array will be completely empty and the other array will have all items that originally were in this array. This operation is very efficient.

Definition at line 344 of file parray.h.


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.2.14