BTree< K, V, ORDER > Class Template Reference
A balanced, n-ary tree data structure for storing key/value relationships.
More...
#include <BTree.h++>
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.
|
| V | 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 |
) |
|
Construct a new BTree with the given maximum capacity.
- Parameters:
-
| capacity | The maximum number of items the tree will hold. |
| virtual ~BTree |
( |
|
) |
[virtual] |
Member Function Documentation
Remove all items from the tree.
| bool contains |
( |
const K |
key |
) |
const |
Determine if an item with the given key exists in the tree.
- Parameters:
-
- Returns:
- true if there is a matching key in the tree, false otherwise.
| void dump |
( |
std::ostream & |
stream |
) |
const |
Dump a representation of the tree (keys only) to a stream.
- Parameters:
-
| stream | The stream to write to. |
Get an item from the tree.
- Parameters:
-
- Returns:
- The data associated with the key, otherwise a NULL value.
| size_t getCapacity |
( |
|
) |
const throw () [inline] |
| void getKeys |
( |
std::list< K > & |
keys |
) |
const |
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 |
Get a list of all of the values in the tree, in access-order.
- Parameters:
-
| values | The list in which to store the values. |
| virtual void itemDropped |
( |
V |
data |
) |
const [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 | |
|
) |
| | |
Put a new item in the tree.
- Parameters:
-
| key | The key. |
| data | The data to associate with the key. |
| bool remove |
( |
const K |
key |
) |
|
Remove an item from the tree.
- Parameters:
-
The documentation for this class was generated from the following file: