Libftpp
A modern C++ library
Node< TType > Class Template Reference

Node structure for an n-ary tree. More...

#include <n_ary_tree.hpp>

Public Member Functions

 Node (TType value)
 
void addChild (const TType &child)
 
Node< TType > * setParentFunct (std::function< TType(std::vector< TType >)> func)
 

Public Attributes

TType data
 
std::vector< std::unique_ptr< Node< TType > > > _children
 
std::function< TType(std::vector< TType >)> parentFunct
 

Detailed Description

template<typename TType>
class Node< TType >

Node structure for an n-ary tree.

Each node contains data and pointers to its children.

Note
You can change Node struct like you want for your implementation. (like add token, parent pointer, etc.)

Definition at line 15 of file n_ary_tree.hpp.

Constructor & Destructor Documentation

◆ Node()

template<typename TType >
Node< TType >::Node ( TType  value)
inline

Definition at line 21 of file n_ary_tree.hpp.

Member Function Documentation

◆ addChild()

template<typename TType >
void Node< TType >::addChild ( const TType &  child)
inline

Definition at line 23 of file n_ary_tree.hpp.

References Node< TType >::_children.

◆ setParentFunct()

template<typename TType >
Node<TType>* Node< TType >::setParentFunct ( std::function< TType(std::vector< TType >)>  func)
inline

Definition at line 28 of file n_ary_tree.hpp.

References Node< TType >::parentFunct.

Member Data Documentation

◆ _children

template<typename TType >
std::vector<std::unique_ptr<Node<TType> > > Node< TType >::_children

◆ data

template<typename TType >
TType Node< TType >::data

◆ parentFunct

template<typename TType >
std::function<TType(std::vector<TType>)> Node< TType >::parentFunct