dune-functions 2.9.0
|
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... | |
TreeData & | operator= (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 Tree * | tree_ |
RawContainer | data_ |
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.
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. |
using Dune::Functions::TreeData< T, ND, LO >::NodeData = ND<Node> |
Template to determine the data type for given node type.
|
protected |
using Dune::Functions::TreeData< T, ND, LO >::size_type = typename Tree::size_type |
Type used for indices and size information.
using Dune::Functions::TreeData< T, ND, LO >::Tree = T |
Type of tree the data is associated with.
|
inline |
Default constructor.
|
inline |
Copy constructor.
|
inline |
Destructor.
|
inline |
Destroy data.
|
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.
|
inline |
Copy assignment.
|
inline |
Get mutable reference to data associated to given node.
|
inline |
Get reference to data associated to given node.
|
protected |
|
static |
Set if data should only be associated to the leafs.
|
protected |