Elm
1.0
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 elm::stree::Tree< K, T, C >::node_t |
elm::stree::Tree< K, T, C >::Tree | ( | void | ) |
Build an empty tree.
elm::stree::Tree< K, T, C >::Tree | ( | int | _root, |
node_t * | _nodes | ||
) |
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. |
elm::stree::Tree< K, T, C >::~Tree | ( | void | ) |
bool elm::stree::Tree< K, T, C >::contains | ( | const K & | key | ) | const |
Referenced by elm::stree::Tree< K, T, C >::find().
|
protected |
const T & elm::stree::Tree< K, T, C >::get | ( | const K & | key, |
const T & | def | ||
) | const |
Find the value associated with the given key. If not found, return the default value.
key | Key to look for. |
def | Default value. |
References elm::stree::Tree< K, T, C >::find().
Referenced by elm::SimpleGC::mark().
const T & elm::stree::Tree< K, T, C >::get | ( | const K & | key | ) | const |
Find a value by its key or raise an assertion failure.
key | Key to look for. |
References elm::stree::Tree< K, T, C >::find().
T& elm::stree::Tree< K, T, C >::get | ( | const K & | key | ) |
References elm::stree::Tree< K, T, C >::find().
void elm::stree::Tree< K, T, C >::set | ( | int | _root, |
node_t * | _nodes | ||
) |
Initialize the current tree with the current configuration.
_root | Index of root node in the node array. |
_nodes | List of nodes. |
Referenced by elm::stree::MarkerBuilder< K, T, C >::make(), and elm::stree::SegmentBuilder< K, T, C >::make().