CrystalSpace

Public API Reference

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

csPArray Class Template Reference

An array of pointers. More...

#include <parray.h>

List of all members.

Public Methods

 csPArray (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...

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

void TransferTo (csPArray< 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...

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

T *& operator[] (int n)
 Get a reference. 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...

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 csPArray< 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. If you want elements to be deleted (with 'delete') you can use csPDelArray instead of this one. Warning! This array doesn't initializate the pointer to NULL for new elements in the array. You have to do that on your own.

Definition at line 38 of file parray.h.


Constructor & Destructor Documentation

template<class T>
csPArray< T >::csPArray 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 49 of file parray.h.

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

Destroy the container.

Definition at line 76 of file parray.h.


Member Function Documentation

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

Delete the given element from vector.

Definition at line 209 of file parray.h.

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

Delete element number 'n' from vector.

Definition at line 191 of file parray.h.

Referenced by csPArray< iMovable >::Delete.

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

Clear entire vector.

Definition at line 63 of file parray.h.

Referenced by csPArray< iMovable >::SetLength, csPArray< iMovable >::TransferTo, and csPArray< iMovable >::~csPArray.

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

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

Definition at line 152 of file parray.h.

Referenced by csPArray< iMovable >::Delete, and csPArray< iMovable >::PushSmart.

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

Find an element based on some key.

Definition at line 237 of file parray.h.

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

Get a pointer.

Definition at line 129 of file parray.h.

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

Insert element 'Item' before element 'n'.

Definition at line 217 of file parray.h.

Referenced by csPArray< iMovable >::InsertSorted.

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

Insert an element at a sorted position.

Assumes array is already sorted.

Definition at line 259 of file parray.h.

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

Query vector length.

Definition at line 117 of file parray.h.

Referenced by csPArray< iMovable >::Find, csPArray< iMovable >::FindSortedKey, csObjectWatcher::GetWatchedLightCount, csObjectWatcher::GetWatchedMovableCount, and csPArray< iMovable >::InsertSorted.

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

Query vector limit.

Definition at line 123 of file parray.h.

template<class T>
T*& csPArray< T >::operator[] int    n [inline]
 

Get a reference.

Definition at line 143 of file parray.h.

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

Get a const reference.

Definition at line 136 of file parray.h.

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

Pop an element from vector 'top'.

Definition at line 177 of file parray.h.

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

Push a element on 'top' of vector.

Definition at line 162 of file parray.h.

Referenced by csPArray< iMovable >::PushSmart.

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

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

Definition at line 170 of file parray.h.

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

Set vector length to n.

Definition at line 99 of file parray.h.

Referenced by csPArray< iMovable >::Delete, csPArray< iMovable >::Insert, csPArray< iMovable >::operator[], csPArray< iMovable >::Pop, and csPArray< iMovable >::Push.

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

Return the top element but don't remove it.

Definition at line 185 of file parray.h.

template<class T>
void csPArray< T >::TransferTo csPArray< 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 87 of file parray.h.


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