Class ADT.CritBit.StringTree

Description

This class implements a CritBit-tree/trie that can be used as a mapping-like data structure. Values of string 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(string:mixed).

Example
ADT.CritBit.StringTree tree = ADT.CritBit.StringTree();
string key1 = "foo";
tree[key1] = ({ 7, 8, 9 });
tree[key1]; // now is ({ 7, 8, 9 })
m_delete(tree, key1); // tree is empty again
Example
ADT.CritBit.StringTree tree = ADT.CritBit.StringTree();
array(string) a = ({ "fooo", "bar", "ahead" });
foreach(a; int idx; string val) {
	tree[val] = idx;
}
foreach(tree; string key; mixed val) {
	// in here the keys will be reached in order "ahead", "bar" and "foo".
}
Example
ADT.CritBit.StringTree tree = ADT.CritBit.StringTree();
array(string) a = ({ "fooo", "bar", "ahead" });
foreach (a; int idx; string val) {
	tree[val] = idx;
}
foreach(ADT.CritBit.StringTree.Iterator (tree, -1); string key; mixed val) {
	// in here the keys will be reached in order "foo", "bar" and "ahead".
}
See also

ADT.CritBit.StringTree.Iterator


Method create

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

Description

Create a StringTree from o.