A STL like tree class. More...
#include <tree.hpp>
Public Types | |
typedef t_tree_node< T > | t_node |
typedef T | value_type |
typedef tree_iterator< T > | iterator |
typedef const_tree_iterator< T > | const_iterator |
typedef tree_sibling_iterator< T > | sibling_iterator |
typedef const_tree_sibling_iterator< T > | const_sibling_iterator |
typedef tree_subtree_iterator< T > | subtree_iterator |
typedef const_tree_subtree_iterator< T > | const_subtree_iterator |
typedef tree_leaf_iterator< T > | leaf_iterator |
typedef const_tree_leaf_iterator< T > | const_leaf_iterator |
typedef std::reverse_iterator< iterator > | reverse_iterator |
typedef std::reverse_iterator< const_iterator > | const_reverse_iterator |
typedef T & | reference |
typedef T * | pointer |
typedef const T & | const_reference |
typedef const T * | const_pointer |
typedef std::pair< sibling_iterator, sibling_iterator > | range_pair |
Public Member Functions | |
tree () | |
~tree () | |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
reverse_iterator | rbegin () |
reverse_iterator | rend () |
const_reverse_iterator | rbegin () const |
const_reverse_iterator | rend () const |
sibling_iterator | begin (const tree_iterator_base< T > &i) |
sibling_iterator | end (const tree_iterator_base< T > &i) |
const_sibling_iterator | begin (const tree_iterator_base< T > &i) const |
const_sibling_iterator | end (const tree_iterator_base< T > &i) const |
subtree_iterator | begin_subtree (const tree_iterator_base< T > &i) |
subtree_iterator | end_subtree (const tree_iterator_base< T > &i) |
const_subtree_iterator | begin_subtree (const const_tree_iterator_base< T > &i) const |
const_subtree_iterator | begin_subtree (const tree_iterator_base< T > &i) const |
const_subtree_iterator | end_subtree (const const_tree_iterator_base< T > &i) const |
const_subtree_iterator | end_subtree (const tree_iterator_base< T > &i) const |
leaf_iterator | begin_leaf () |
const_leaf_iterator | begin_leaf () const |
leaf_iterator | end_leaf () |
const_leaf_iterator | end_leaf () const |
size_t | size () const |
size_t | size (const tree_iterator_base< T > &i) const |
bool | empty () const |
bool | empty (const tree_iterator_base< T > &x) const |
void | clear () |
template<typename iter > | |
iter | erase (iter i) |
template<typename iter > | |
void | move (iter a, iter b) |
template<typename iter > | |
iter | insert (iter i, const T &x) |
template<typename iter > | |
iter | push_back_child (iter i, const T &v) |
template<typename iter > | |
iter | push_front_child (iter i, const T &v) |
void | sort_children (tree_iterator_base< T > &i) |
template<typename CMP > | |
void | sort_children (tree_iterator_base< T > &i, CMP cmp) |
void | sort () |
template<typename CMP > | |
void | sort (CMP cmp) |
template<typename Predicate > | |
range_pair | equal_range (const tree_iterator_base< T > &i, Predicate predicate) const |
iterator | parent (const tree_iterator_base< T > &i) const |
template<typename iter , typename Predicate > | |
iterator | find_in_path (iter pfirst, iter plast, Predicate predicate) |
size_t | depth (const tree_iterator_base< T > &i) const |
size_t | depth (const const_tree_iterator_base< T > &i) const |
size_t | depth (const reverse_iterator &i) const |
size_t | depth (const const_reverse_iterator &i) const |
A STL like tree class.
The tree class provides a container with an STL like interface. One can store data in it a like tree. There are several iterator types, find methods and modify (insert, push_back/front) methods. Access is provide via iterators.
typedef const_tree_iterator<T> matador::tree< T >::const_iterator |
Shortcut to default const iterator type
typedef const_tree_leaf_iterator<T> matador::tree< T >::const_leaf_iterator |
Shortcut to const leaf iterator type
typedef const T* matador::tree< T >::const_pointer |
Shortcut to value const pointer type
typedef const T& matador::tree< T >::const_reference |
Shortcut to value const reference type
typedef std::reverse_iterator<const_iterator> matador::tree< T >::const_reverse_iterator |
Shortcut to const reverse iterator type
typedef const_tree_sibling_iterator<T> matador::tree< T >::const_sibling_iterator |
Shortcut to const sibling iterator type
typedef const_tree_subtree_iterator<T> matador::tree< T >::const_subtree_iterator |
Shortcut to const subtree iterator type
typedef tree_iterator<T> matador::tree< T >::iterator |
Shortcut to default iterator type
typedef tree_leaf_iterator<T> matador::tree< T >::leaf_iterator |
Shortcut to leaf iterator type
typedef T* matador::tree< T >::pointer |
Shortcut to value pointer type
typedef std::pair<sibling_iterator, sibling_iterator> matador::tree< T >::range_pair |
Shortcut to a range pair type
typedef T& matador::tree< T >::reference |
Shortcut to value reference type
typedef std::reverse_iterator<iterator> matador::tree< T >::reverse_iterator |
Shortcut to reverse iterator type
typedef tree_sibling_iterator<T> matador::tree< T >::sibling_iterator |
Shortcut to sibling iterator type
typedef tree_subtree_iterator<T> matador::tree< T >::subtree_iterator |
Shortcut to subtree iterator type
typedef t_tree_node<T> matador::tree< T >::t_node |
Shortcut to node type
typedef T matador::tree< T >::value_type |
Shortcut to value type
matador::tree< T >::tree | ( | ) |
Creates an empty tree of type T.
matador::tree< T >::~tree | ( | ) |
Cleans up the tree but not the stored data.
|
inline |
Returns the begin iterator of the tree
|
inline |
Returns the constant begin iterator of the tree
|
inline |
Returns the sibling begin iterator for a node (iterator)
i |
|
inline |
Returns the constant sibling begin iterator for a node (iterator)
i |
|
inline |
Return the first leaf node as iterator
|
inline |
Return the first leaf node as constant iterator
|
inline |
Returns the constant subtree begin iterator for a node (iterator)
i |
|
inline |
Returns the subtree begin iterator for a node (iterator)
i |
|
inline |
Returns the constant subtree begin iterator for a node (iterator)
i |
void matador::tree< T >::clear | ( | ) |
Empties the tree
|
inline |
Returns the depth of the given node constant reverse iterator i
i | constant reverse iterator for which the depth is returned |
size_t matador::tree< T >::depth | ( | const const_tree_iterator_base< T > & | i | ) | const |
Returns the depth of the given node constant iterator i
i | constant iterator for which the depth is returned |
|
inline |
Returns the depth of the given node reverse iterator i
i | reverse iterator for which the depth is returned |
size_t matador::tree< T >::depth | ( | const tree_iterator_base< T > & | i | ) | const |
Returns the depth of the given node iterator i
i | iterator for which the depth is returned |
|
inline |
Returns wether the tree is empty or not
|
inline |
Returns if iterator has children
x | iterator used for empty check |
|
inline |
Returns the end iterator of the tree
|
inline |
Returns the constant end iterator of the tree
|
inline |
Returns the sibling end iterator for a node (iterator)
i |
|
inline |
Returns the constant sibling end iterator for a node (iterator)
i |
|
inline |
Return the end leaf node as iterator
|
inline |
Return the first leaf node as constant iterator
|
inline |
Returns the constant subtree end iterator for a node (iterator)
i |
|
inline |
Returns the subtree end iterator for a node (iterator)
i |
|
inline |
Returns the constant subtree end iterator for a node (iterator)
i |
range_pair matador::tree< T >::equal_range | ( | const tree_iterator_base< T > & | i, |
Predicate | predicate | ||
) | const |
Returns two iterators representing a range of children nodes which equals a given predicate (e.g. same name) Note: children must be sorted, otherwise a range of all nodes equaling the predicate can't be guaranted!
i | parent iterator of future range children |
predicate | which all range children must equal |
Erase iterator i from tree include the complete subtree
i | the iterator to erase |
iterator matador::tree< T >::find_in_path | ( | iter | pfirst, |
iter | plast, | ||
Predicate | predicate | ||
) |
Search a node within a given path. Path comes as two iterators pfirst and plast over which can be iterated.
pfirst | the first iterator of path |
plast | the last iterator of path |
predicate | the search rule for the node to find |
Insert as previous sibling of i and returns new node iterator
i | next sibling of new node |
x | new node of type T |
Moves subtree represented by iterator a and insert before iterator b
a | iterator to move |
b | iterator where insertion takes place (before) |
iterator matador::tree< T >::parent | ( | const tree_iterator_base< T > & | i | ) | const |
Returns the parent node of iterator. if iterator hasn't a parent node end() is returned
i | iterator to get the parent from |
iter matador::tree< T >::push_back_child | ( | iter | i, |
const T & | v | ||
) |
Insert as last child of i and returns new node iterator
i | parent children of new node of type T |
v | new node of type T |
iter matador::tree< T >::push_front_child | ( | iter | i, |
const T & | v | ||
) |
Insert as first child of i and returns new node iterator
i | parent children of new node of type T |
v | new node of type T |
|
inline |
Returns the reverse begin iterator of the tree
|
inline |
Returns the constant reverse begin iterator of the tree
|
inline |
Returns the reverse end iterator of the tree
|
inline |
Returns the constant reverse end iterator of the tree
|
inline |
Returns the current size of the tree (takes linear amount of time)
|
inline |
Returns the current amount of children of the given node (takes linear amount of time)
void matador::tree< T >::sort | ( | ) |
Sorts the complete tree with the standard compare method. But the sorting is done for all siblings (children of a node) discretely
Sorts the complete tree with the given compare method. But the sorting is done for all siblings (children of a node) discretely
cmp | compare operator |
void matador::tree< T >::sort_children | ( | tree_iterator_base< T > & | i | ) |
Sort children of iterator node i with standard compare operator
i | parent node of children to sort |
void matador::tree< T >::sort_children | ( | tree_iterator_base< T > & | i, |
CMP | cmp | ||
) |
Sort children of iterator node i with compare operator of type CMP
i | parent node of children to sort |
cmp | compare operator |