CrystalSpace

Public API Reference

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

csVector Class Reference

#include <csvector.h>

Inheritance diagram for csVector:

csBasicVector csConstraintVector csHintManager csRGBVector csSkin csStrVector csWSTexVector List of all members.

Public Methods

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

virtual ~csVector ()
 Destroy the vector object. More...

int FindKey (const void *Key, int Mode=0) const
 Find a element by key (using CompareKey method). More...

int FindSortedKey (const void *Key, int Mode=0) const
 Find a element in a SORTED array by key (using CompareKey method). More...

void QuickSort (int Left, int Right, int Mode=0)
 Partially sort the array. More...

void QuickSort (int Mode=0)
 Same but for all elements. More...

bool Delete (int n, bool FreeIt=true)
 Delete element number 'n' from vector. More...

bool Delete (void *Item, bool FreeIt=true)
 Delete the given element from vector. More...

bool Replace (int n, void *what, bool FreePrevious=true)
 Replace n-th item with another (free previous value). More...

void DeleteAll (bool FreeThem=true)
 Delete all elements. More...

int InsertSorted (void *Item, int *oEqual=NULL, int Mode=0)
 Insert element 'Item' so that array remains sorted (assumes its already). More...

virtual bool FreeItem (void *Item)
 Virtual function which frees a vector element; returns success status. More...

virtual int Compare (void *Item1, void *Item2, int Mode) const
 Compare two array elements in given Mode. More...

virtual int CompareKey (void *Item, const void *Key, int Mode) const
 Compare entry with a key; for csVector just compare (int)Key vs (int)Item. More...


Detailed Description

Deprecated:
Use csArray, csGrowingArray, csRefArray or csPArray instead.
csVector is an abstract class which can hold an unlimited array of unspecified (void*) data. Since this is a basic object, it does not presume anything about its elements, so FreeItem() is effectively a no-op. If you want vector elements to free automatically occupied memory upon vector destruction you should create a derived class which should provide its own FreeItem() method (see csStrVector for a example).

Note that FreeItem() returns a boolean value which is the success status. This is used in Delete() and DeleteAll() to decide whenever an element can be really deleted - if the element has a good reason to stay 'sticky' it can return false from FreeItem().

Definition at line 114 of file csvector.h.


Constructor & Destructor Documentation

csVector::csVector int    ilimit = 8,
int    ithreshold = 16
[inline]
 

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

Definition at line 121 of file csvector.h.

virtual csVector::~csVector   [inline, virtual]
 

Destroy the vector object.

Definition at line 125 of file csvector.h.


Member Function Documentation

virtual int csVector::Compare void *    Item1,
void *    Item2,
int    Mode
const [virtual]
 

Compare two array elements in given Mode.

Reimplemented in csStrVector.

virtual int csVector::CompareKey void *    Item,
const void *    Key,
int    Mode
const [virtual]
 

Compare entry with a key; for csVector just compare (int)Key vs (int)Item.

Reimplemented in csStrVector.

bool csVector::Delete void *    Item,
bool    FreeIt = true
[inline]
 

Delete the given element from vector.

Definition at line 229 of file csvector.h.

References Delete, and csBasicVector::Find.

bool csVector::Delete int    n,
bool    FreeIt = true
 

Delete element number 'n' from vector.

Referenced by csTreeNode::BSF, Delete, and csTreeNode::RemoveChild.

void csVector::DeleteAll bool    FreeThem = true
 

Delete all elements.

Referenced by csTreeNode::BSF.

int csVector::FindKey const void *    Key,
int    Mode = 0
const
 

Find a element by key (using CompareKey method).

Referenced by csWSTexVector::FindTexture.

int csVector::FindSortedKey const void *    Key,
int    Mode = 0
const
 

Find a element in a SORTED array by key (using CompareKey method).

Referenced by csSparseGrid::GetAt.

virtual bool csVector::FreeItem void *    Item [virtual]
 

Virtual function which frees a vector element; returns success status.

Reimplemented in csStrVector.

int csVector::InsertSorted void *    Item,
int *    oEqual = NULL,
int    Mode = 0
 

Insert element 'Item' so that array remains sorted (assumes its already).

Referenced by csSparseGrid::GetAt.

void csVector::QuickSort int    Mode = 0 [inline]
 

Same but for all elements.

Definition at line 236 of file csvector.h.

References QuickSort.

void csVector::QuickSort int    Left,
int    Right,
int    Mode = 0
 

Partially sort the array.

Referenced by QuickSort.

bool csVector::Replace int    n,
void *    what,
bool    FreePrevious = true
 

Replace n-th item with another (free previous value).


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