dune-functions 2.9.0
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Types | Protected Attributes | List of all members
Dune::Functions::TreeData< T, ND, LO > Class Template Reference

Container allowing to attach data to each node of a tree. More...

#include <dune/functions/common/treedata.hh>

Classes

struct  CopyVisitor
 
struct  DestroyVisitor
 
struct  InitVisitor
 

Public Types

using Tree = T
 Type of tree the data is associated with. More...
 
using size_type = typename Tree::size_type
 Type used for indices and size information. More...
 
template<class Node >
using NodeData = ND< Node >
 Template to determine the data type for given node type. More...
 

Public Member Functions

 TreeData ()
 Default constructor. More...
 
void init (const Tree &tree)
 Initialize from tree. More...
 
 TreeData (const TreeData &other)
 Copy constructor. More...
 
TreeDataoperator= (const TreeData &other)
 Copy assignment. More...
 
void destroy ()
 Destroy data. More...
 
 ~TreeData ()
 Destructor. More...
 
template<class Node >
NodeData< Node > & operator[] (const Node &node)
 Get mutable reference to data associated to given node. More...
 
template<class Node >
const NodeData< Node > & operator[] (const Node &node) const
 Get reference to data associated to given node. More...
 

Static Public Attributes

static const bool leafOnly = LO
 Set if data should only be associated to the leafs. More...
 

Protected Types

using RawContainer = std::vector< void * >
 

Protected Attributes

const Treetree_
 
RawContainer data_
 

Detailed Description

template<class T, template< class > class ND, bool LO>
class Dune::Functions::TreeData< T, ND, LO >

Container allowing to attach data to each node of a tree.

Deprecated:

This provides operator[](Node) for accessing the data attached to the node. For storing the data each node is identified via its treeIndex() method which is supposed to return an index which is unique wrt the tree. These indices need not to be consecutive but they are used to access an internal vector<void*>. This may lead to wasted memory if the maximal treeIndex() is much larger then the number of nodes within the tree.

Before using the container it must be initialized by providing the tree. The stored data objects will be created on initialization. Hence the type of these data objects must be default constructible.

Notice that the data per node can only be interpreted if the node type is known. Hence the tree will be traversed on initialization, copy, assignment, and destruction of a TreeData container.

Template Parameters
TType of the tree
NDThe data stored for a node of type Node will be of type ND<Node>
LOSet this flag if data should only be attached to leaf nodes.

Member Typedef Documentation

◆ NodeData

template<class T , template< class > class ND, bool LO>
template<class Node >
using Dune::Functions::TreeData< T, ND, LO >::NodeData = ND<Node>

Template to determine the data type for given node type.

◆ RawContainer

template<class T , template< class > class ND, bool LO>
using Dune::Functions::TreeData< T, ND, LO >::RawContainer = std::vector<void*>
protected

◆ size_type

template<class T , template< class > class ND, bool LO>
using Dune::Functions::TreeData< T, ND, LO >::size_type = typename Tree::size_type

Type used for indices and size information.

◆ Tree

template<class T , template< class > class ND, bool LO>
using Dune::Functions::TreeData< T, ND, LO >::Tree = T

Type of tree the data is associated with.

Constructor & Destructor Documentation

◆ TreeData() [1/2]

template<class T , template< class > class ND, bool LO>
Dune::Functions::TreeData< T, ND, LO >::TreeData ( )
inline

Default constructor.

◆ TreeData() [2/2]

template<class T , template< class > class ND, bool LO>
Dune::Functions::TreeData< T, ND, LO >::TreeData ( const TreeData< T, ND, LO > &  other)
inline

Copy constructor.

◆ ~TreeData()

template<class T , template< class > class ND, bool LO>
Dune::Functions::TreeData< T, ND, LO >::~TreeData ( )
inline

Destructor.

Member Function Documentation

◆ destroy()

template<class T , template< class > class ND, bool LO>
void Dune::Functions::TreeData< T, ND, LO >::destroy ( )
inline

Destroy data.

◆ init()

template<class T , template< class > class ND, bool LO>
void Dune::Functions::TreeData< T, ND, LO >::init ( const Tree tree)
inline

Initialize from tree.

This default creates the data object associated to each node in the tree. A reference to the tree is stored because it's needed for destruction of the tree data.

◆ operator=()

template<class T , template< class > class ND, bool LO>
TreeData & Dune::Functions::TreeData< T, ND, LO >::operator= ( const TreeData< T, ND, LO > &  other)
inline

Copy assignment.

◆ operator[]() [1/2]

template<class T , template< class > class ND, bool LO>
template<class Node >
NodeData< Node > & Dune::Functions::TreeData< T, ND, LO >::operator[] ( const Node &  node)
inline

Get mutable reference to data associated to given node.

◆ operator[]() [2/2]

template<class T , template< class > class ND, bool LO>
template<class Node >
const NodeData< Node > & Dune::Functions::TreeData< T, ND, LO >::operator[] ( const Node &  node) const
inline

Get reference to data associated to given node.

Member Data Documentation

◆ data_

template<class T , template< class > class ND, bool LO>
RawContainer Dune::Functions::TreeData< T, ND, LO >::data_
protected

◆ leafOnly

template<class T , template< class > class ND, bool LO>
const bool Dune::Functions::TreeData< T, ND, LO >::leafOnly = LO
static

Set if data should only be associated to the leafs.

◆ tree_

template<class T , template< class > class ND, bool LO>
const Tree* Dune::Functions::TreeData< T, ND, LO >::tree_
protected

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