Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/stree/Tree.h>
Classes | |
struct | node_t |
Public Types | |
typedef struct elm::stree::Tree::node_t | node_t |
Public Member Functions | |
Tree (void) | |
Tree (int _root, node_t *_nodes) | |
void | set (int _root, node_t *_nodes) |
~Tree (void) | |
const T & | get (const K &key, const T &def) const |
const T & | get (const K &key) const |
T & | get (const K &key) |
bool | contains (const K &key) const |
Protected Member Functions | |
T * | find (const K &key) const |
A segmented tree allows to retrieve items associated with a segment, that is, a value range. The access is quite fast (log2(n)) but the creation of the tree is not dynamic: all segment must be provided at creation time.
To help to build such a structure, several builder are provided:
K | Key type. |
T | Retrieven item type. |
C | Comparator to compare keys (default to Comparator<K>). |
typedef struct elm::stree::Tree::node_t node_t |
Build form the given list of nodes. The tree is responsible to release the node array at destruction time.
_root | Index of root node in the node array. |
_nodes | List of nodes. |
|
inline |
Referenced by Tree< K, T, C >::find().
|
inlineprotected |
References Tree< K, T, C >::contains(), Tree< K, T, C >::node_t::data, Tree< K, T, C >::node_t::left(), Tree< K, T, C >::node_t::right(), and elm::io::right().
Referenced by Tree< K, T, C >::get().
|
inline |
References Tree< K, T, C >::find().
|
inline |
Find a value by its key or raise an assertion failure.
key | Key to look for. |
References Tree< K, T, C >::find().
|
inline |
Find the value associated with the given key. If not found, return the default value.
key | Key to look for. |
def | Default value. |
References Tree< K, T, C >::find().
Referenced by GroupedGC::mark(), and SimpleGC::mark().
Initialize the current tree with the current configuration.
_root | Index of root node in the node array. |
_nodes | List of nodes. |
Referenced by MarkerBuilder< K, T, C >::make(), and SegmentBuilder< K, T, C >::make().