6#ifndef DUNE_TYPETREE_TRAVERSALUTILITIES_HH
7#define DUNE_TYPETREE_TRAVERSALUTILITIES_HH
27 template<
typename F,
typename R,
typename ResultType>
28 struct LeafReductionVisitor
29 :
public TypeTree::TreeVisitor
34 template<
typename Node,
typename TreePath>
35 void leaf(
const Node& node, TreePath treePath)
37 _value = _reduction(_value,_functor(node,treePath));
40 LeafReductionVisitor(F functor, R reduction, ResultType startValue)
42 , _reduction(reduction)
46 ResultType result() {
return _value; }
82 template<
typename ResultType,
typename Tree,
typename F,
typename R>
83 ResultType
reduceOverLeafs(
const Tree& tree, F functor, R reduction, ResultType startValue)
85 LeafReductionVisitor<F,R,ResultType> visitor(functor,reduction,startValue);
87 return visitor.result();
ResultType reduceOverLeafs(const Tree &tree, F functor, R reduction, ResultType startValue)
Calculate a quantity as a reduction over the leaf nodes of a TypeTree.
Definition traversalutilities.hh:83
void applyToTree(Tree &&tree, Visitor &&visitor)
Apply visitor to TypeTree.
Definition traversal.hh:184
Definition accumulate_static.hh:17
Definition accumulate_static.hh:18
Type
Definition treepath.hh:108
@ dynamic
Definition treepath.hh:108