Class ADT.CritBit.FloatTree
- Description
This class implements a CritBit-tree/trie that can be used as a mapping-like data structure. Values of
float|int
can be used as indices, while any possible type (alsomixed
) 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 likemapping(float|int:mixed)
.- Example
ADT.CritBit.FloatTree tree = ADT.CritBit.FloatTree(); float|int key1 = 12.0; tree[key1] = ({ 4, 5, 6 }); tree[key1]; // now is ({ 4, 5, 6 }) m_delete(tree, key1); // tree is empty again
- Example
ADT.CritBit.FloatTree tree = ADT.CritBit.FloatTree(); array(float|int) a = ({ 80.4, 99.9, 14.2 }); foreach(a; int idx; float|int val) { tree[val] = idx; } foreach(tree; float|int key; mixed val) { // in here the keys will be reached in order 14.2, 80.4 and 99.9. }
- Example
ADT.CritBit.FloatTree tree = ADT.CritBit.FloatTree(); array(float|int) a = ({ 80.4, 99.9, 14.2 }); foreach (a; int idx; float|int val) { tree[val] = idx; } foreach(ADT.CritBit.FloatTree.Iterator(tree, -1); float|int key; mixed val) { // in here the keys will be reached in order 99.9, 80.4 and 14.2. }
- See also
ADT.CritBit.FloatTree.Iterator
- Method create
ADT.CritBit.FloatTree ADT.CritBit.FloatTree(
array
|mapping
|void
o
)- Description
Create a FloatTree from o.