23 #ifndef __ccxx_BTree_hxx 24 #define __ccxx_BTree_hxx 31 #ifdef CCXX_OS_WINDOWS 50 template <
typename K,
typename V,
int ORDER = 10>
class BTree 55 enum _Status { BTreeOK, BTreeOverflow, BTreeDuplicate, BTreeUnderflow,
68 _Datum* keys[ORDER * 2];
69 _Node* children[ORDER * 2 + 1];
73 _Node() : parent(NULL), count(0)
75 for(
int i = 0; i <= ORDER * 2; i++)
94 _Status insertNode(_Datum* key, _Node* node, _Datum** rkey, _Node** rnode);
95 _Status deleteNode(K key, _Node* node);
96 void _dump(_Node* node,
int depth, std::ostream& stream)
const;
98 void unlink(_Datum* datum);
99 void link(_Datum* datum);
129 bool put(
const K key,
const V data);
136 bool remove(
const K key);
160 void dump(std::ostream& stream)
const;
167 void getKeys(std::list<K>& keys)
const;
174 void getValues(std::list<V>& values)
const;
181 {
return(_capacity); }
203 virtual void rewind();
205 virtual bool hasNext();
206 virtual void remove();
210 #include <commonc++/BTreeImpl.h++> 214 #endif // __ccxx_BTree_hxx
virtual void itemDropped(V data) const
Called whenever an item is removed from the BTree to make room for another.
void getKeys(std::list< K > &keys) const
Get a list of all of the keys in the tree, in access-order.
virtual ~Iterator()
Destructor.
Definition: BTree.h++:201
unsigned int uint_t
An alias for unsigned int.
Definition: Integers.h++:74
void clear()
Remove all items from the tree.
void dump(std::ostream &stream) const
Dump a representation of the tree (keys only) to a stream.
void getValues(std::list< V > &values) const
Get a list of all of the values in the tree, in access-order.
A balanced, n-ary tree data structure for storing key/value relationships.
Definition: BTree.h++:50
uint_t getCapacity() const
Get the tree capacity.
Definition: BTree.h++:180
A BTree iterator.
Definition: BTree.h++:188
bool put(const K key, const V data)
Put a new item in the tree.
A Java-style iterator.
Definition: Iterator.h++:35
BTree(uint_t capacity)
Construct a new BTree with the given maximum capacity.
bool contains(const K key) const
Determine if an item with the given key exists in the tree.
virtual ~BTree()
Destructor.
Definition: AllocationMap.c++:25