Pike v8.0 release 1738

Class ADT.CritBit.IntTree

Description

This class implements a CritBit-tree/trie that can be used as a mapping-like data structure. Values of int can be used as indices, while any possible type (also mixed) can be stored.

CritBit trees are prefixed based search trees that allow for fast random access as well as prefix and range based lookups. Keys are stored in alphabetical order and can be iterated over using foreach. Other than that, it can be used like mapping(int:mixed).

Example
ADT.CritBit.IntTree tree = ADT.CritBit.IntTree();
int key1 = 12;
tree[key1] = ({ 1, 2 ,3 });
tree[key1]; // now is ({ 1, 2 ,3 })
m_delete(tree, key1); // tree is empty again
Example
ADT.CritBit.IntTree tree = ADT.CritBit.IntTree();
array(int) a = ({ 1025, 15000, 3 });
foreach(a; int idx; int val) {
tree[val] = idx;
}
foreach(tree; int key; mixed val) {
// in here the keys will be reached in order 3, 1025 and 15000.
}
Example
ADT.CritBit.IntTree tree = ADT.CritBit.IntTree();
array(int) a = ({ 1025, 15000, 3 });
foreach (a; int idx; int val) {
tree[val] = idx;
}
foreach(ADT.CritBit.IntTree.Iterator(tree, -1); int key; mixed val) {
// in here the keys will be reached in order 15000, 1025 and 3.
}
See also

ADT.CritBit.IntTree.Iterator


Method create

ADT.CritBit.IntTree ADT.CritBit.IntTree(array|mapping|void o)

Description

Create a IntTree from o.