Class ADT.CritBit.IPv4Tree

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.IPv4Tree tree = ADT.CritBit.IPv4Tree();
string key1 = "127.0.0.0/8";
tree[key1] = "reject";
tree[key1]; // now is "reject"
m_delete(tree, key1); // tree is empty again
Example
ADT.CritBit.IPv4Tree tree = ADT.CritBit.IPv4Tree();
array(string) a = ({ "10.243.7.1", "127.0.0.1/8", "172.16.5.2" });
foreach(a; int idx; string val) {
	tree[val] = idx;
}
foreach(tree; string key; mixed val) {
	// in here the keys will be reached in order "10.243.7.1", "127.0.0.1/8" and "172.16.5.2".
}
Example
ADT.CritBit.IPv4Tree tree = ADT.CritBit.IPv4Tree();
array(string) a = ({ "10.243.7.1", "127.0.0.1/8", "172.16.5.2" });
foreach (a; int idx; string val) {
	tree[val] = idx;
}
foreach(ADT.CritBit.IPv4Tree.Iterator (tree, -1); string key; mixed val) {
	// in here the keys will be reached in order "172.16.5.2", "127.0.0.1/8" and "10.243.7.1".
}
See also

ADT.CritBit.IPv4Tree.Iterator


Method create

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

Description

Create a IPv4Tree from o.