[ VIGRA Homepage |
Class Index |
Function Index |
File Index |
Main Page ]
|
ReduceFunctor Class Template Reference
|
 |
Apply a functor to reduce the dimensionality of an array.
More...
#include "vigra/inspectimage.hxx"
template<class FUNCTOR, class VALUETYPE>
class vigra::ReduceFunctor< FUNCTOR, VALUETYPE >
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:
FUNCTOR f;
VALUETYPE accumulator, current1, current2;
f(accumulator, current1);
f(accumulator, current1, current2);
Member Typedef Documentation
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 actuall 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 actuall a template parameter.) |
typedef VALUETYPE result_type
|
|
|
the functor's result type |
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 actuall a template parameter.) |
Constructor & Destructor Documentation
ReduceFunctor |
( |
FUNCTOR const & |
f, |
|
|
VALUETYPE const & |
initial |
|
) |
[inline] |
|
|
create with the given functor and initial value initial for the accumulator. |
Member Function Documentation
void operator() |
( |
T1 const & |
v1, |
|
|
T2 const & |
v2 |
|
) |
[inline] |
|
|
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. |
void operator() |
( |
T const & |
v |
) |
[inline] |
|
|
Use binary functor to connect given value with the accumulator. The accumulator is used as the first argument, the value v as the second. |
|
Reset accumulator to the initial value. |
The documentation for this class was generated from the following file: