aimstil  5.0.5
til::NaryTree< T, N > Class Template Reference

A class to represent an N-ary tree. More...

#include <til/til_declarations.h>

Inheritance diagram for til::NaryTree< T, N >:

Classes

class  const_iterator
 Const iterator on n-ary trees. More...
 
struct  Destructor
 
class  iterator
 Non-const iterator on n-ary trees. More...
 
class  Node
 Internal class used inside binary tree. More...
 
class  TreeRootAlreadyDefined
 

Public Member Functions

 NaryTree ()
 Default constructor builds an emtpy tree. More...
 
 ~NaryTree ()
 Destructor. More...
 
std::size_t size () const
 
const_iterator root () const
 Return a const iterator on the root element of the tree. More...
 
iterator root ()
 Return a non_const iterator on the root element of the tree. More...
 
iterator addChild (Node *parent, std::size_t childNumber, T value=T())
 Add a child to a node. More...
 
iterator addChild (iterator &parent, std::size_t childNumber, T value=T())
 Add a child to a node. More...
 

Detailed Description

template<typename T, std::size_t N>
class til::NaryTree< T, N >

A class to represent an N-ary tree.

An N-ary tree is a tree with N numbered branches at each node. Of course, not all of these branches need to be there. But the fact that these branches are numbered (till N) has a meaning: a node having only one branch is only part of the story; whether this branch is number 0 or number 7 is also an information stored in the tree. From that point of view, a tree is not a graph – or then, it is a graph with valued edges. The type of the value stored at each node is of type T. This could be anything – including pointers on actual values. A tree is a container, but it is also much more than a container. Therefore the iterators can be used just like STL iterators, but have also other tree-specific functionalities.

Definition at line 29 of file til_declarations.h.

Constructor & Destructor Documentation

◆ NaryTree()

template<typename T, std::size_t N>
til::NaryTree< T, N >::NaryTree ( )
inline

Default constructor builds an emtpy tree.

Definition at line 60 of file binary_tree.h.

◆ ~NaryTree()

template<typename T, std::size_t N>
til::NaryTree< T, N >::~NaryTree ( )

Member Function Documentation

◆ addChild() [1/2]

template<typename T, std::size_t N>
iterator til::NaryTree< T, N >::addChild ( Node parent,
std::size_t  childNumber,
value = T() 
)

◆ addChild() [2/2]

template<typename T, std::size_t N>
NaryTree< T, N >::iterator til::NaryTree< T, N >::addChild ( iterator parent,
std::size_t  childNumber,
value = T() 
)
inline

Add a child to a node.

Definition at line 339 of file binary_tree.h.

◆ root() [1/2]

template<typename T , std::size_t N>
NaryTree< T, N >::const_iterator til::NaryTree< T, N >::root ( ) const
inline

Return a const iterator on the root element of the tree.

Definition at line 328 of file binary_tree.h.

Referenced by til::NaryTree< KDNode< TIndex >, 2 >::size().

◆ root() [2/2]

template<typename T , std::size_t N>
NaryTree< T, N >::iterator til::NaryTree< T, N >::root ( )
inline

Return a non_const iterator on the root element of the tree.

Definition at line 333 of file binary_tree.h.

◆ size()

template<typename T, std::size_t N>
std::size_t til::NaryTree< T, N >::size ( ) const
inline

Definition at line 67 of file binary_tree.h.


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