BTree< K, V, ORDER > Class Template Reference

A balanced, n-ary tree data structure for storing key/value relationships. More...

#include <BTree.h++>

Collaboration diagram for BTree< K, V, ORDER >:

Collaboration graph
[legend]

List of all members.

Classes

struct  _Datum
struct  _Node
class  Iterator
 A BTree iterator. More...

Public Member Functions

 BTree (size_t capacity)
 Construct a new BTree with the given maximum capacity.
virtual ~BTree ()
 Destructor.
bool put (const K key, const V data)
 Put a new item in the tree.
bool remove (const K key)
 Remove an item from the tree.
get (const K key)
 Get an item from the tree.
bool contains (const K key) const
 Determine if an item with the given key exists in the tree.
void dump (std::ostream &stream) const
 Dump a representation of the tree (keys only) to a stream.
void getKeys (std::list< K > &keys) const
 Get a list of all of the keys in the tree, in access-order.
void getValues (std::list< V > &values) const
 Get a list of all of the values in the tree, in access-order.
void clear ()
 Remove all items from the tree.
size_t getCapacity () const throw ()
 Get the tree capacity.

Protected Member Functions

virtual void itemDropped (V data) const
 Called whenever an item is removed from the BTree to make room for another.


Detailed Description

template<typename K, typename V, int ORDER = 10>
class ccxx::BTree< K, V, ORDER >

A balanced, n-ary tree data structure for storing key/value relationships.

The BTree has a configurable order and maximum capacity. The items are ordered internally by last access time. When the maximum capacity has been reached, and a new item is added to the tree, the least-recently accessed item is automatically removed.

Author:
Mark Lindner

Constructor & Destructor Documentation

BTree ( size_t  capacity  )  [inline]

Construct a new BTree with the given maximum capacity.

Parameters:
capacity The maximum number of items the tree will hold.

~BTree (  )  [inline, virtual]

Destructor.


Member Function Documentation

void clear (  )  [inline]

Remove all items from the tree.

bool contains ( const K  key  )  const [inline]

Determine if an item with the given key exists in the tree.

Parameters:
key The key.
Returns:
true if there is a matching key in the tree, false otherwise.

void dump ( std::ostream &  stream  )  const [inline]

Dump a representation of the tree (keys only) to a stream.

Parameters:
stream The stream to write to.

V get ( const K  key  )  [inline]

Get an item from the tree.

Parameters:
key The key.
Returns:
The data associated with the key, otherwise a NULL value.

size_t getCapacity (  )  const throw () [inline]

Get the tree capacity.

void getKeys ( std::list< K > &  keys  )  const [inline]

Get a list of all of the keys in the tree, in access-order.

Parameters:
keys The list in which to store the keys.

void getValues ( std::list< V > &  values  )  const [inline]

Get a list of all of the values in the tree, in access-order.

Parameters:
values The list in which to store the values.

void itemDropped ( data  )  const [inline, protected, virtual]

Called whenever an item is removed from the BTree to make room for another.

Parameters:
data The value that was removed.

bool put ( const K  key,
const V  data 
) [inline]

Put a new item in the tree.

Parameters:
key The key.
data The data to associate with the key.

bool remove ( const K  key  )  [inline]

Remove an item from the tree.

Parameters:
key The key.


The documentation for this class was generated from the following file:

Generated on Sat Apr 17 23:03:07 2010 for libcommonc++ by  doxygen 1.5.9