Dune Core Modules (2.8.0)

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>

Public Types

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

Public Member Functions

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

Static Public Attributes

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

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.

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 initilization, 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 Function Documentation

◆ 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.

References Dune::TypeTree::applyToTree(), and Dune::Functions::TreeData< T, ND, LO >::destroy().


The documentation for this class was generated from the following file:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)