Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
|
Class introducing a forward_tree with interface trying to be close to the interface of standard library containers. More...
#include <forward_tree.hpp>
Data Structures | |
class | const_postfix_iterator |
The iterator type over structure of the tree following postorder traversal. More... | |
class | const_prefix_iterator |
The iterator type over structure of the tree following preorder traversal. More... | |
class | const_structure_iterator |
The iterator type over structure of the tree representing nodes and node_ends. More... | |
Public Types | |
typedef ext::vector< forward_tree >::const_iterator | const_children_iterator |
The iterator type over children of the node. More... | |
typedef ext::vector< forward_tree >::iterator | children_iterator |
The iterator type over children of the node. More... | |
Public Member Functions | |
T & | getData () |
Getter of the value in the root node. More... | |
const T & | getData () const |
Getter of the value in the root node. More... | |
ext::vector< forward_tree > & | getChildren () |
Getter of children of the root node. More... | |
const ext::vector< forward_tree > & | getChildren () const |
Getter of children of the root node. More... | |
const_children_iterator | insert (const_children_iterator position, forward_tree< T > &&value) |
Inserts a subtree into a forward_tree. More... | |
const_children_iterator | insert (const_children_iterator position, const forward_tree< T > &value) |
Inserts a subtree into a forward_tree. More... | |
const_children_iterator | insert (const_children_iterator position, const_children_iterator begin, const_children_iterator end) |
Insert helper for insertion specified by position in children and inserted subtrees given by range of iterators. More... | |
template<class Iterator > | |
const_children_iterator | insert (const_children_iterator position, Iterator begin, Iterator end) |
Inserts a subtrees into a forward_tree. The subtrees are nullary nodes having value given by values in the range begin to end. More... | |
forward_tree (T &&data, ext::vector< forward_tree > &&children) | |
Constructor of the forward_tree from value to be stored in the root node and children trees. More... | |
forward_tree (const T &data, const ext::vector< forward_tree > &subtrees) | |
Constructor of the forward_tree from value to be stored in the root node and children trees. More... | |
template<typename ... Types> | |
forward_tree (const T &data, Types ... subtrees) | |
Constructor of the forward_tree from value to be stored in the root node and pack of children trees. More... | |
template<typename ... Types> | |
forward_tree (T &&data, Types ... subtrees) | |
Constructor of the forward_tree from value to be stored in the root node and pack of children trees. More... | |
template<typename Iterator > | |
forward_tree (const T &data, Iterator begin, Iterator end) | |
Constructor of the forward_tree from value to be stored in the root node and range of values to construct nullary nodes from range of values. More... | |
forward_tree (const T &data, const_children_iterator begin, const_children_iterator end) | |
Constructor of the forward_tree from value to be stored in the root node and range of subtrees. More... | |
const_children_iterator | begin () const |
Getter of a children iterator to the begining of children. More... | |
children_iterator | begin () |
Getter of a children iterator to the begining of children. More... | |
const_children_iterator | end () const |
Getter of a children iterator one after the last child. More... | |
children_iterator | end () |
Getter of a children iterator one after the last child. More... | |
const_prefix_iterator | prefix_begin () const |
Getter of the prefix iterator to the root node. More... | |
const_prefix_iterator | prefix_end () const |
Getter of the prefix iterator one after the last node in the prefix traversal. More... | |
const_postfix_iterator | postfix_begin () const |
Getter of the postfix iterator to the first node in the postfix traversal. More... | |
const_postfix_iterator | postfix_end () const |
Getter of the postfix iterator one after the last node in the postfix traversal. More... | |
const_structure_iterator | structure_begin () const |
Getter of the structure iterator to the first node in the traversal. More... | |
const_structure_iterator | structure_end () const |
Getter of the structure iterator to one after the last node in the traversal. More... | |
void | push_back (ext::forward_tree< T > &&value) |
Pushbacks a subtree after last child of a tree. More... | |
void | push_back (const ext::forward_tree< T > &value) |
Pushbacks a subtree after last child of a tree. More... | |
void | push_back (T &&value) |
Pushbacks a nullary node after last child of a tree. More... | |
void | push_back (const T &value) |
Pushbacks a nullary node after last child of a tree. More... | |
children_iterator | erase (const_children_iterator position) |
Erases a subtree from a tree on given by position . More... | |
template<class ... Indexes> | |
const T & | operator() (Indexes ... indexes) const |
Access value given indexes of chindren allong the selection path. More... | |
const T & | operator() (std::initializer_list< size_t > indexes) const |
Access value given indexes of chindren allong the selection path. More... | |
template<class ... Indexes> | |
T & | operator() (Indexes ... indexes) |
Access value given indexes of chindren allong the selection path. More... | |
T & | operator() (std::initializer_list< size_t > indexes) |
Access value given indexes of chindren allong the selection path. More... | |
bool | operator== (const forward_tree &other) const |
Equality comparison operator. More... | |
auto | operator<=> (const forward_tree &other) const |
Less comparison operator. More... | |
std::ostream & | nicePrint (std::ostream &os) const |
Internal method of printing a tree into a stream. More... | |
Friends | |
void | swap (forward_tree &first, forward_tree &second) |
Swap method of two forward trees. More... | |
Class introducing a forward_tree with interface trying to be close to the interface of standard library containers.
The tree is a hierarchical structure of nodes with parent child relationship, where the children are ordered and indexed by integers.
Nodes of the forward tree do not store pointers to their parent node.
T | the type of values inside nodes of the forward_tree |
typedef ext::vector<forward_tree>::iterator ext::forward_tree< T >::children_iterator |
The iterator type over children of the node.
typedef ext::vector<forward_tree>::const_iterator ext::forward_tree< T >::const_children_iterator |
The iterator type over children of the node.
|
inline |
Constructor of the forward_tree from value to be stored in the root node and children trees.
data | the value to be stored in the root |
children | list of subtrees |
|
inline |
Constructor of the forward_tree from value to be stored in the root node and children trees.
data | the value to be stored in the root |
children | list of subtrees |
|
inline |
Constructor of the forward_tree from value to be stored in the root node and pack of children trees.
Types | ... pack of types convertible to forward_trees |
data | the value to be stored in the root |
subtrees | ... pack of subtrees |
|
inline |
Constructor of the forward_tree from value to be stored in the root node and pack of children trees.
Types | ... pack of types convertible to forward_trees |
data | the value to be stored in the root |
subtrees | ... pack of subtrees |
|
inline |
Constructor of the forward_tree from value to be stored in the root node and range of values to construct nullary nodes from range of values.
data | the value to be stored in the root |
begin | the iterator to the begining of values range |
end | the iterator to the end of values range |
|
inline |
Constructor of the forward_tree from value to be stored in the root node and range of subtrees.
data | the value to be stored in the root |
begin | the iterator to the begining of subtree range |
end | the iterator to the end of subtree range |
|
inline |
Getter of a children iterator to the begining of children.
|
inline |
Getter of a children iterator to the begining of children.
|
inline |
Getter of a children iterator one after the last child.
|
inline |
Getter of a children iterator one after the last child.
|
inline |
Erases a subtree from a tree on given by position
.
position | the specification of position in children where to erase the subtree |
|
inline |
Getter of children of the root node.
|
inline |
Getter of children of the root node.
|
inline |
Getter of the value in the root node.
|
inline |
Getter of the value in the root node.
|
inline |
Inserts a subtree into a forward_tree.
position | the specification of position in children of the node where to add subtrees |
value | a subtree to insert |
|
inline |
Insert helper for insertion specified by position in children and inserted subtrees given by range of iterators.
position | the specification of position in children of the node where to add subtrees |
begin | the start of the range of subtrees |
end | the end of the range of subtrees |
|
inline |
Inserts a subtree into a forward_tree.
position | the specification of position in children of the node where to add subtrees |
value | a subtree to insert |
|
inline |
Inserts a subtrees into a forward_tree. The subtrees are nullary nodes having value given by values in the range begin to end.
Iterator | the type of iterators forming the range |
position | the specification of position in children of the node where to add subtrees |
begin | the start of the range of values |
end | the end of the range of values |
|
inline |
Internal method of printing a tree into a stream.
The tree is printed hierarchically.
Example tree a ( b ( c ), b ( c ) ) would be printed like
-a | |-b | | | -c | -b | -c
os | the stream to print to |
|
inline |
Access value given indexes of chindren allong the selection path.
Indexes | ... types of child indexes |
indexes | actual values of child indexes |
|
inline |
Access value given indexes of chindren allong the selection path.
Indexes | ... types of child indexes |
indexes | actual values of child indexes |
|
inline |
Access value given indexes of chindren allong the selection path.
indexes | actual values of child indexes |
|
inline |
Access value given indexes of chindren allong the selection path.
indexes | actual values of child indexes |
|
inline |
Less comparison operator.
other | the other instance to compare with |
|
inline |
Equality comparison operator.
other | the other instance to compare with |
|
inline |
Getter of the postfix iterator to the first node in the postfix traversal.
|
inline |
Getter of the postfix iterator one after the last node in the postfix traversal.
|
inline |
Getter of the prefix iterator to the root node.
|
inline |
Getter of the prefix iterator one after the last node in the prefix traversal.
|
inline |
Pushbacks a subtree after last child of a tree.
value | a subtree to pushback to child list |
|
inline |
Pushbacks a nullary node after last child of a tree.
value | a value to store in nullary node push-backed to the child list |
|
inline |
Pushbacks a subtree after last child of a tree.
value | a subtree to pushback to child list |
|
inline |
Pushbacks a nullary node after last child of a tree.
value | a value to store in nullary node push-backed to the child list |
|
inline |
Getter of the structure iterator to the first node in the traversal.
|
inline |
Getter of the structure iterator to one after the last node in the traversal.
|
friend |
Swap method of two forward trees.
first | the first forward tree to swap |
second | the second forward tree to swap |