DiaDes  0.1
DIAgnosis of Discrete-Event System
Classes | Public Member Functions | Private Attributes | List of all members
Diades::Utils::NAryTree< Node, Leaf, _Map > Class Template Reference

#include <NAryTree.hh>

Classes

class  TreeBranches
 
class  TreeElement
 
class  TreeLeaf
 

Public Member Functions

 NAryTree ()=default
 Default constructor. More...
 
 NAryTree (NAryTree const &other)=default
 
NAryTreeoperator= (NAryTree const &other)=default
 
 NAryTree (NAryTree &&other)=default
 
NAryTreeoperator= (NAryTree &&other)=default
 
 ~NAryTree ()=default
 Destructor. More...
 
template<typename NodeIterator >
Leaf & insertSuccessiveBranches (NodeIterator begin, NodeIterator end, const Leaf &info)
 
template<typename NodeIterator >
bool getLeaf (NodeIterator begin, NodeIterator end, Leaf &result)
 
void clear ()
 

Private Attributes

std::unique_ptr< TreeBranches_firstBranches
 

Detailed Description

template<typename Node, typename Leaf, template< typename, typename > class _Map>
class Diades::Utils::NAryTree< Node, Leaf, _Map >

This class is a specific n-ary tree of nodes. Each branch of the tree ends with a node associated with a leaf. The way the branches are connected with their root is a Map. Be aware that is not possible to associated a Leaf to a sub-branch. This class is used to for instance to implement State tables that associates to a vector of local states (State = Node) a global information (Leaf)

After some tests the use of _Map=std::map is slower than _Map=std::unordered_map (Node = int) (Leaf = string) however this looks having the same computational trend. From a memory consumption point of view it is also pretty equivalent. The reason that the way we use it generates small maps or hash-maps, the problem being the number of map/hash-map involved in the tree.

Definition at line 35 of file NAryTree.hh.

Constructor & Destructor Documentation

◆ NAryTree() [1/3]

template<typename Node, typename Leaf, template< typename, typename > class _Map>
Diades::Utils::NAryTree< Node, Leaf, _Map >::NAryTree ( )
default

Default constructor.

◆ NAryTree() [2/3]

template<typename Node, typename Leaf, template< typename, typename > class _Map>
Diades::Utils::NAryTree< Node, Leaf, _Map >::NAryTree ( NAryTree< Node, Leaf, _Map > const &  other)
default

Copy constructor (default)

Parameters
other

◆ NAryTree() [3/3]

template<typename Node, typename Leaf, template< typename, typename > class _Map>
Diades::Utils::NAryTree< Node, Leaf, _Map >::NAryTree ( NAryTree< Node, Leaf, _Map > &&  other)
default

Move constructor (default)

Parameters
other

◆ ~NAryTree()

template<typename Node, typename Leaf, template< typename, typename > class _Map>
Diades::Utils::NAryTree< Node, Leaf, _Map >::~NAryTree ( )
default

Destructor.

Member Function Documentation

◆ clear()

template<typename Node, typename Leaf, template< typename, typename > class _Map>
void Diades::Utils::NAryTree< Node, Leaf, _Map >::clear ( )
inline

clear the tree

Definition at line 337 of file NAryTree.hh.

Referenced by Diades::Automata::Experimental::ComposableModel< Fsm, StateCreator >::init().

◆ getLeaf()

template<typename Node, typename Leaf, template< typename, typename > class _Map>
template<typename NodeIterator >
bool Diades::Utils::NAryTree< Node, Leaf, _Map >::getLeaf ( NodeIterator  begin,
NodeIterator  end,
Leaf &  result 
)
inline
Parameters
beginthe starting iterator over a range of Nodes
endthe ending iterator over a range of Nodes
resultthe Leaf that is associated to the nodes'range if it exists, undetermined otherwise
Returns
true if the leaf exists

Definition at line 324 of file NAryTree.hh.

Referenced by Diades::Automata::Experimental::ComposableModel< Fsm, StateCreator >::newState().

◆ insertSuccessiveBranches()

template<typename Node, typename Leaf, template< typename, typename > class _Map>
template<typename NodeIterator >
Leaf& Diades::Utils::NAryTree< Node, Leaf, _Map >::insertSuccessiveBranches ( NodeIterator  begin,
NodeIterator  end,
const Leaf &  info 
)
inline

Insert a leaf associated with the Node range [begin,end[ Be aware that if a leaf already exists, it is replaced. If a branch associated to a range bigger than [begin,end[ already exists, it is removed.

Parameters
beginthe starting iterator over a range of Nodes
endthe ending iterator over a range of Nodes
infothe piece of information that will be associated with the range in the tree
Returns
a reference to the inserted leaf

Definition at line 304 of file NAryTree.hh.

Referenced by Diades::Utils::NAryTree< Node, Leaf, _Map >::TreeBranches::insertSuccessiveBranches(), and Diades::Automata::Experimental::ComposableModel< Fsm, StateCreator >::newState().

◆ operator=() [1/2]

template<typename Node, typename Leaf, template< typename, typename > class _Map>
NAryTree& Diades::Utils::NAryTree< Node, Leaf, _Map >::operator= ( NAryTree< Node, Leaf, _Map > const &  other)
default

Assignement (default)

Parameters
other
Returns
the current NAryTree

◆ operator=() [2/2]

template<typename Node, typename Leaf, template< typename, typename > class _Map>
NAryTree& Diades::Utils::NAryTree< Node, Leaf, _Map >::operator= ( NAryTree< Node, Leaf, _Map > &&  other)
default

Move assignement (default)

Parameters
other
Returns
the current NAryTree

Member Data Documentation

◆ _firstBranches

template<typename Node, typename Leaf, template< typename, typename > class _Map>
std::unique_ptr<TreeBranches> Diades::Utils::NAryTree< Node, Leaf, _Map >::_firstBranches
private

Definition at line 257 of file NAryTree.hh.


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