![]() |
Quetzal-CoaTL
The Coalescence Template Library
|
#include <quetzal/coalescence/container/Tree.hpp>
Data structure for representing tree topologies where each node contains a data field.
CellT | Cell type, ie the value of the node. The requirements that are imposed on CellT depend on the actual operations performed on Tree<CellT>. |
Public Member Functions | |
Tree () | |
Default constructor. | |
Tree (const CellT &cell) | |
Constructor with data copy. | |
Tree (CellT &&cell) noexcept | |
Constructor with data move. | |
Tree (const Tree< CellT > &other) | |
Copy constructor. | |
Tree (Tree< CellT > &&other) noexcept | |
Move constructor. | |
Tree (CellT &&cell, std::vector< Tree< CellT > > &&children) noexcept | |
Constructor. | |
Tree< CellT > & | operator= (const Tree< CellT > &other) |
Copy assignment operator. | |
Tree< CellT > & | operator= (Tree< CellT > &&other) noexcept |
Move assignment operator. | |
const CellT & | cell () const |
Cell accessor. | |
CellT & | cell () |
Cell accessor. | |
Tree< CellT > & | add_child (const Tree< CellT > &subtree) |
Add a subtree to the children list of the tree. | |
Tree< CellT > & | add_child (Tree< CellT > &&subtree) noexcept |
Add a subtree to the children list of the tree. | |
Tree< CellT > & | add_child (CellT &&cell) noexcept |
Add a subtree to the children list of the tree, initialize the tree. | |
bool | has_parent () const |
Checks whether the tree has a parent. | |
bool | has_children () const |
Checks whether the tree has one or more child. | |
template<typename UnaryOperation > | |
void | visit_cells_by_pre_order_DFS (UnaryOperation op) const |
Applies a function object to each node encountered in a depth first search algorithm. | |
template<class UnaryOperation > | |
void | visit_subtrees_by_pre_order_DFS (UnaryOperation op) |
Applies a function object to each node encountered in a depth first search algorithm. | |
template<typename Op1 , typename Op2 , typename Op3 > | |
void | visit_subtrees_by_generic_DFS (Op1 preorder, Op2 inorder, Op3 postorder) |
auto & | parent () |
auto const & | parent () const |
unsigned int | nb_children () const |
template<typename UnaryOperation > | |
void | visit_leaves_cells_by_DFS (UnaryOperation op) const |
Applies a function object to each leave encountered in a depth first search algorithm. | |
quetzal::coalescence::container::Tree< CellT >::Tree | ( | ) |
Default constructor.
quetzal::coalescence::container::Tree< CellT >::Tree | ( | const CellT & | cell | ) |
Constructor with data copy.
cell | the value of the tree cell |
|
noexcept |
Constructor with data move.
cell | the value of the tree cell |
quetzal::coalescence::container::Tree< CellT >::Tree | ( | const Tree< CellT > & | other | ) |
Copy constructor.
other | the tree to be constructed from |
|
noexcept |
Move constructor.
other | the tree to be constructed from |
|
noexcept |
Constructor.
cell | the value of the tree cell |
children | a vector of subtrees |
|
noexcept |
Add a subtree to the children list of the tree, initialize the tree.
cell | the cell value of the subtree to be added |
Tree< CellT > & quetzal::coalescence::container::Tree< CellT >::add_child | ( | const Tree< CellT > & | subtree | ) |
Add a subtree to the children list of the tree.
subtree | the subtree to be added |
|
noexcept |
Add a subtree to the children list of the tree.
subtree | the subtree to be added |
CellT & quetzal::coalescence::container::Tree< CellT >::cell | ( | ) |
Cell accessor.
const CellT & quetzal::coalescence::container::Tree< CellT >::cell | ( | ) | const |
Cell accessor.
bool quetzal::coalescence::container::Tree< CellT >::has_children | ( | ) | const |
Checks whether the tree has one or more child.
|
inline |
Checks whether the tree has a parent.
Tree< CellT > & quetzal::coalescence::container::Tree< CellT >::operator= | ( | const Tree< CellT > & | other | ) |
Copy assignment operator.
|
noexcept |
Move assignment operator.
|
inline |
Applies a function object to each node encountered in a depth first search algorithm.
op | unary operation function object that will be applied to the data member/// of the tree. The unary operator takes the cell as argument. The signature of the function should be equivalent to the following: void op(const CellT & cell); . |
|
inline |
Applies a function object to each leave encountered in a depth first search algorithm.
op | unary operation function object that will be applied to the data member of the tree. The unary operator takes the cell as argument. The signature of the function should be equivalent to the following: void op(const CellT & cell); . |
|
inline |
Applies a function object to each node encountered in a depth first search algorithm.
op | unary operation function object that will be applied to the data member/// of the tree. The unary operator takes the cell as argument. The signature of the function should be equivalent to the following: void op(CellT & cell); . |