CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

csTree< T > Class Template Reference

A generic binary search tree. More...

#include <csutil/bintree.h>

List of all members.

Public Member Functions

 csTree (int blocksize=15)
 Construct a tree that allocates memory for nodes in blocks of the given size.
 csTree (const csTree< T > &other)
 Copy constructor.
void PopulateWith (const csArray< uint32 > &keys, const csArray< T > &values)
 Populate an empty tree with entries from a sorted array.
void Traverse (TraverseFunc *func, void *some) const
 Call a callback function once for every entry in the tree.
void Put (uint32 key, const T &value)
 Put an entry into the tree, overwriting if the key already exists.
T & Find (uint32 key)
 Find the given entry in the tree, creating it if it doesn't exist.
const T & Find (uint32 key) const
 Find the given entry in the tree, returning 0 if it doesn't exist,.
bool Delete (uint32 key)
 Delete the given entry from the tree, returning false if it doesn't exist.
bool DeleteAll ()
 Delete all the entries from the tree.
int GetSize () const
 Get the number of entries in the tree.


Detailed Description

template<class T>
class csTree< T >

A generic binary search tree.

Definition at line 27 of file bintree.h.


Constructor & Destructor Documentation

template<class T>
csTree< T >::csTree int  blocksize = 15  )  [inline]
 

Construct a tree that allocates memory for nodes in blocks of the given size.

Definition at line 111 of file bintree.h.

template<class T>
csTree< T >::csTree const csTree< T > &  other  )  [inline]
 

Copy constructor.

Definition at line 115 of file bintree.h.

References csBlockAllocator< T >::Alloc(), and csTree< T >::Root.


Member Function Documentation

template<class T>
bool csTree< T >::Delete uint32  key  )  [inline]
 

Delete the given entry from the tree, returning false if it doesn't exist.

Definition at line 229 of file bintree.h.

References csBlockAllocator< T >::Free().

template<class T>
bool csTree< T >::DeleteAll  )  [inline]
 

Delete all the entries from the tree.

Definition at line 300 of file bintree.h.

template<class T>
const T& csTree< T >::Find uint32  key  )  const [inline]
 

Find the given entry in the tree, returning 0 if it doesn't exist,.

Definition at line 209 of file bintree.h.

template<class T>
T& csTree< T >::Find uint32  key  )  [inline]
 

Find the given entry in the tree, creating it if it doesn't exist.

Definition at line 175 of file bintree.h.

template<class T>
int csTree< T >::GetSize  )  const [inline]
 

Get the number of entries in the tree.

Definition at line 308 of file bintree.h.

template<class T>
void csTree< T >::PopulateWith const csArray< uint32 > &  keys,
const csArray< T > &  values
[inline]
 

Populate an empty tree with entries from a sorted array.

Definition at line 123 of file bintree.h.

References csArray< T, ElementHandler, MemoryAllocator >::Length().

template<class T>
void csTree< T >::Put uint32  key,
const T &  value
[inline]
 

Put an entry into the tree, overwriting if the key already exists.

Definition at line 137 of file bintree.h.

template<class T>
void csTree< T >::Traverse TraverseFunc *  func,
void *  some
const [inline]
 

Call a callback function once for every entry in the tree.

Definition at line 131 of file bintree.h.


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