|
Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
|
Class introducing a tree with interface trying to be close to the interface of standard library containers. More...
#include <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< tree >::const_iterator | const_children_iterator |
| The iterator type over children of the node. More... | |
| typedef ext::vector< tree >::iterator | children_iterator |
| The iterator type over children of the node. More... | |
Public Member Functions | |
| tree * | getParent () |
| Getter of the parent node. Null if the node is root. More... | |
| const tree * | getParent () const |
| Getter of the parent node. Null if the node is root. More... | |
| 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< tree > & | getChildren () |
| Getter of children of the root node. More... | |
| const ext::vector< tree > & | getChildren () const |
| Getter of children of the root node. More... | |
| const_children_iterator | insert (const_children_iterator position, tree< T > &&value) |
| Inserts a subtree into a tree. More... | |
| const_children_iterator | insert (const_children_iterator position, const tree< T > &value) |
| Inserts a subtree into a tree. More... | |
| const_children_iterator | insert (const_children_iterator position, const_children_iterator begin, const_children_iterator end) |
| Inserts subtrees given by range of values at specified position. More... | |
| template<class Iterator > | |
| const_children_iterator | insert (const_children_iterator position, Iterator begin, Iterator end) |
| Inserts a subtrees into a tree. The subtrees are nullary nodes having value given by values in the range begin to end. More... | |
| tree (T &&data, ext::vector< tree > &&children) | |
| Constructor of the tree from value to be stored in the root node and children trees. More... | |
| tree (const T &data, const ext::vector< tree > &subtrees) | |
| Constructor of the tree from value to be stored in the root node and children trees. More... | |
| template<typename ... Types> | |
| tree (const T &data, Types ... subtrees) | |
| Constructor of the tree from value to be stored in the root node and pack of children trees. More... | |
| template<typename ... Types> | |
| tree (T &&data, Types ... subtrees) | |
| Constructor of the tree from value to be stored in the root node and pack of children trees. More... | |
| template<typename Iterator > | |
| tree (const T &data, Iterator begin, Iterator end) | |
| Constructor of the tree from value to be stored in the root node and range of values to construct nullary nodes from range of values. More... | |
| tree (const T &data, const_children_iterator begin, const_children_iterator end) | |
| Constructor of the tree from value to be stored in the root node and range of subtrees. More... | |
| ~tree () noexcept=default | |
| Dectructor of the tree. More... | |
| tree (const tree &other) | |
| Copy constructor of the tree. More... | |
| tree (tree &&other) noexcept | |
| Move constructor of the tree. More... | |
| tree & | operator= (const tree &node) |
| Copy operator of assignment of the tree. More... | |
| tree & | operator= (tree &&node) noexcept |
| Move operator of assignment of the tree. 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::tree< T > &&value) |
| Pushbacks a subtree after last child of a tree. More... | |
| void | push_back (const ext::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 | checkStructure (const tree &node) const |
| Helper method to traverse the tree and check all parent references are set correctly. More... | |
| bool | checkStructure () const |
| Helper method to traverse the tree and check all parent references are set correctly. Starts at root node and recursively tests all its child nodes. More... | |
| bool | operator== (const tree &other) const |
| Equality comparison operator. More... | |
| auto | operator<=> (const tree &other) const -> decltype(std::declval< T >()<=> std::declval< T >()) |
| Greater or equal comparison operator. More... | |
| ext::ostream & | nicePrint (ext::ostream &os) const |
| Method of printing a tree into a stream. More... | |
Friends | |
| void | swap (tree &first, tree &second) |
| Swap method of two trees. More... | |
Class introducing a 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.
| T | the type of values inside nodes of the tree |
| typedef ext::vector<tree>::iterator ext::tree< T >::children_iterator |
The iterator type over children of the node.
| typedef ext::vector<tree>::const_iterator ext::tree< T >::const_children_iterator |
The iterator type over children of the node.
|
inline |
Constructor of the 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 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 tree from value to be stored in the root node and pack of children trees.
| Types | ... pack of types convertible to tree |
| data | the value to be stored in the root |
| subtrees | ... pack of subtrees |
|
inline |
Constructor of the tree from value to be stored in the root node and pack of children trees.
| Types | ... pack of types convertible to tree |
| data | the value to be stored in the root |
| subtrees | ... pack of subtrees |
|
inline |
Constructor of the 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 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 |
Copy constructor of the tree.
| other | the other instace of the tree |
Move constructor of the tree.
| other | the other instace of the tree |
|
inline |
Getter of a children iterator to the begining of children.
|
inline |
Getter of a children iterator to the begining of children.
|
inline |
Helper method to traverse the tree and check all parent references are set correctly. Starts at root node and recursively tests all its child nodes.
| node | the node to test |
Helper method to traverse the tree and check all parent references are set correctly.
| node | the node to test |
|
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.
Getter of the parent node. Null if the node is root.
Getter of the parent node. Null if the node is root.
|
inline |
Inserts a subtree into a tree.
| position | the specification of position in children of the node where to add subtrees |
| value | a subtree to insert |
|
inline |
Inserts subtrees given by range of values at specified position.
| 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 subtrees into a 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 |
Inserts a subtree into a tree.
| position | the specification of position in children of the node where to add subtrees |
| value | a subtree to insert |
|
inline |
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 |
Greater or equal comparison operator.
| other | the other instance to compare with |
Copy operator of assignment of the tree.
| other | the other instace of the tree |
Move operator of assignment of the tree.
| other | the other instace of the tree |
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.
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 |
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.
Swap method of two trees.
| first | the first tree to swap |
| second | the second tree to swap |