[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]
![]() |
ReduceFunctor< FUNCTOR, VALUETYPE > Class Template Reference | ![]() |
Apply a functor to reduce the dimensionality of an array. More...
#include <vigra/inspectimage.hxx>
Public Types | |
typedef VALUETYPE | argument_type |
typedef VALUETYPE | first_argument_type |
typedef VALUETYPE | result_type |
typedef VALUETYPE | second_argument_type |
Public Member Functions | |
template<class T > | |
void | operator() (T const &v) |
template<class T1 , class T2 > | |
void | operator() (T1 const &v1, T2 const &v2) |
result_type const & | operator() () const |
ReduceFunctor (FUNCTOR const &f, VALUETYPE const &initial) | |
void | reset () |
Apply a functor to reduce the dimensionality of an array.
This functor can be used to emulate the reduce
standard function of functional programming using std::for_each()
or inspectImage()
and similar functions. This functor is initialized with a functor encoding the expression to be applied, and an accumulator storing the current state of the reduction. For each element of the array, the embedded functor is called with the accumulator and the current element(s) of the array. The result of the reduction is available by calling reduceFunctor()
.
Traits defined:
FunctorTraits::isUnaryAnalyser
, FunctorTraits::isBinaryAnalyser
and FunctorTraits::isInitializer
are true (VigraTrueType
)
Usage:
#include <vigra/inspectimage.hxx>
Namespace: vigra
Required Interface:
typedef VALUETYPE argument_type |
the functor's argument type when used as a unary inspector. (This is not strictly correct since the argument type is actually a template parameter.)
typedef VALUETYPE first_argument_type |
the functor's first argument type when used as a binary inspector. (This is not strictly correct since the argument type is actually a template parameter.)
typedef VALUETYPE second_argument_type |
the functor's second argument type when used as a binary inspector. (This is not strictly correct since the argument type is actually a template parameter.)
typedef VALUETYPE result_type |
the functor's result type
ReduceFunctor | ( | FUNCTOR const & | f, |
VALUETYPE const & | initial | ||
) |
create with the given functor and initial value initial for the accumulator.
void reset | ( | ) |
Reset accumulator to the initial value.
void operator() | ( | T const & | v | ) |
Use binary functor to connect given value with the accumulator. The accumulator is used as the first argument, the value v as the second.
void operator() | ( | T1 const & | v1, |
T2 const & | v2 | ||
) |
Use ternary functor to connect given values with accumulator. The accumulator is used as the first argument, the values v1 ans v2 as the second and third.
result_type const& operator() | ( | ) | const |
return current value
© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) |
html generated using doxygen and Python
|