Dune Core Modules (2.9.0)
Container allowing to attach data to each node of a tree. More...
#include <dune/functions/common/treedata.hh>
Public Member Functions | |
TreeData () | |
Default constructor. | |
void | init (const Tree &tree) |
Initialize from tree. More... | |
TreeData (const TreeData &other) | |
Copy constructor. | |
TreeData & | operator= (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
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 initialization, copy, assignment, and destruction of a TreeData container.
- Template Parameters
-
T Type of the tree ND The data stored for a node of type Node will be of type ND<Node> LO Set this flag if data should only be attached to leaf nodes.
Member Function Documentation
◆ init()
|
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().
The documentation for this class was generated from the following file:
- dune/functions/common/treedata.hh