|
libcommonc++
0.7
|
A balanced, n-ary tree data structure for storing key/value relationships. More...
#include <BTree.h++>
Classes | |
| class | Iterator |
| A BTree iterator. More... | |
Public Member Functions | |
| BTree (uint_t capacity) | |
| Construct a new BTree with the given maximum capacity. More... | |
| virtual | ~BTree () |
| Destructor. More... | |
| bool | put (const K key, const V data) |
| Put a new item in the tree. More... | |
| bool | remove (const K key) |
| Remove an item from the tree. More... | |
| V | get (const K key) |
| Get an item from the tree. More... | |
| bool | contains (const K key) const |
| Determine if an item with the given key exists in the tree. More... | |
| void | dump (std::ostream &stream) const |
| Dump a representation of the tree (keys only) to a stream. More... | |
| void | getKeys (std::list< K > &keys) const |
| Get a list of all of the keys in the tree, in access-order. More... | |
| void | getValues (std::list< V > &values) const |
| Get a list of all of the values in the tree, in access-order. More... | |
| void | clear () |
| Remove all items from the tree. More... | |
| uint_t | getCapacity () const |
| Get the tree capacity. More... | |
Protected Member Functions | |
| virtual void | itemDropped (V data) const |
| Called whenever an item is removed from the BTree to make room for another. More... | |
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.
Construct a new BTree with the given maximum capacity.
| capacity | The maximum number of items the tree will hold. |
|
virtual |
Destructor.
| void clear | ( | ) |
Remove all items from the tree.
| bool contains | ( | const K | key | ) | const |
Determine if an item with the given key exists in the tree.
| key | The key. |
| void dump | ( | std::ostream & | stream | ) | const |
Dump a representation of the tree (keys only) to a stream.
| stream | The stream to write to. |
| V get | ( | const K | key | ) |
Get an item from the tree.
| key | The key. |
|
inline |
Get the tree capacity.
| void getKeys | ( | std::list< K > & | keys | ) | const |
Get a list of all of the keys in the tree, in access-order.
| 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.
| values | The list in which to store the values. |
|
protectedvirtual |
Called whenever an item is removed from the BTree to make room for another.
| data | The value that was removed. |
| bool put | ( | const K | key, |
| const V | data | ||
| ) |
Put a new item in the tree.
| key | The key. |
| data | The data to associate with the key. |
| bool remove | ( | const K | key | ) |
Remove an item from the tree.
| key | The key. |