Quetzal-CoaTL
The Coalescence Template Library
Loading...
Searching...
No Matches
quetzal::coalescence::container::Tree< CellT > Class Template Reference

#include <quetzal/coalescence/container/Tree.hpp>

Detailed Description

template<class CellT>
class quetzal::coalescence::container::Tree< CellT >

Data structure for representing tree topologies where each node contains a data field.

Template Parameters
CellTCell 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.
 

Constructor & Destructor Documentation

◆ Tree() [1/6]

template<typename CellT >
quetzal::coalescence::container::Tree< CellT >::Tree ( )

Default constructor.

Remarks
CellT must be default constructible

◆ Tree() [2/6]

template<typename CellT >
quetzal::coalescence::container::Tree< CellT >::Tree ( const CellT &  cell)

Constructor with data copy.

Parameters
cellthe value of the tree cell
Remarks
CellT must be copy constructible.

◆ Tree() [3/6]

template<typename CellT >
quetzal::coalescence::container::Tree< CellT >::Tree ( CellT &&  cell)
noexcept

Constructor with data move.

Parameters
cellthe value of the tree cell
Remarks
CellT must be move constructible.

◆ Tree() [4/6]

template<class CellT >
quetzal::coalescence::container::Tree< CellT >::Tree ( const Tree< CellT > &  other)

Copy constructor.

Parameters
otherthe tree to be constructed from
Remarks
CellT must be copy constructible.

◆ Tree() [5/6]

template<class CellT >
quetzal::coalescence::container::Tree< CellT >::Tree ( Tree< CellT > &&  other)
noexcept

Move constructor.

Parameters
otherthe tree to be constructed from
Remarks
CellT must be move constructible.

◆ Tree() [6/6]

template<class CellT >
quetzal::coalescence::container::Tree< CellT >::Tree ( CellT &&  cell,
std::vector< Tree< CellT > > &&  children 
)
noexcept

Constructor.

Parameters
cellthe value of the tree cell
childrena vector of subtrees
Remarks
CellT must be move constructible.

Member Function Documentation

◆ add_child() [1/3]

template<class CellT >
Tree< CellT > & quetzal::coalescence::container::Tree< CellT >::add_child ( CellT &&  cell)
noexcept

Add a subtree to the children list of the tree, initialize the tree.

Parameters
cellthe cell value of the subtree to be added
Returns
a reference on the new subtree

◆ add_child() [2/3]

template<class CellT >
Tree< CellT > & quetzal::coalescence::container::Tree< CellT >::add_child ( const Tree< CellT > &  subtree)

Add a subtree to the children list of the tree.

Parameters
subtreethe subtree to be added
Returns
a reference on the new subtree

◆ add_child() [3/3]

template<class CellT >
Tree< CellT > & quetzal::coalescence::container::Tree< CellT >::add_child ( Tree< CellT > &&  subtree)
noexcept

Add a subtree to the children list of the tree.

Parameters
subtreethe subtree to be added
Returns
a reference on the new subtree

◆ cell() [1/2]

template<class CellT >
CellT & quetzal::coalescence::container::Tree< CellT >::cell ( )

Cell accessor.

Returns
a reference to the tree cell
Remarks
Read-and-write data access

◆ cell() [2/2]

template<class CellT >
const CellT & quetzal::coalescence::container::Tree< CellT >::cell ( ) const

Cell accessor.

Returns
a const-reference to the tree cell
Remarks
Read-only data access

◆ has_children()

template<class CellT >
bool quetzal::coalescence::container::Tree< CellT >::has_children ( ) const

Checks whether the tree has one or more child.

Returns
Returns false if the tree has no child, else returns true.

◆ has_parent()

template<class CellT >
bool quetzal::coalescence::container::Tree< CellT >::has_parent ( ) const
inline

Checks whether the tree has a parent.

Returns
Returns true if the tree has a parent, else returns false.

◆ operator=() [1/2]

template<class CellT >
Tree< CellT > & quetzal::coalescence::container::Tree< CellT >::operator= ( const Tree< CellT > &  other)

Copy assignment operator.

Remarks
CellT must be copy constructible and move assignable.

◆ operator=() [2/2]

template<class CellT >
Tree< CellT > & quetzal::coalescence::container::Tree< CellT >::operator= ( Tree< CellT > &&  other)
noexcept

Move assignment operator.

Remarks
CellT must be move assignable.

◆ visit_cells_by_pre_order_DFS()

template<class CellT >
template<typename UnaryOperation >
void quetzal::coalescence::container::Tree< CellT >::visit_cells_by_pre_order_DFS ( UnaryOperation  op) const
inline

Applies a function object to each node encountered in a depth first search algorithm.

Parameters
opunary 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);.

◆ visit_leaves_cells_by_DFS()

template<class CellT >
template<typename UnaryOperation >
void quetzal::coalescence::container::Tree< CellT >::visit_leaves_cells_by_DFS ( UnaryOperation  op) const
inline

Applies a function object to each leave encountered in a depth first search algorithm.

Parameters
opunary 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);.

◆ visit_subtrees_by_pre_order_DFS()

template<class CellT >
template<class UnaryOperation >
void quetzal::coalescence::container::Tree< CellT >::visit_subtrees_by_pre_order_DFS ( UnaryOperation  op)
inline

Applies a function object to each node encountered in a depth first search algorithm.

Parameters
opunary 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);.

The documentation for this class was generated from the following file: