Trait rayon::par_iter::reduce::ReduceOp
[−]
[src]
pub trait ReduceOp<T>: Sync {
fn start_value(&self) -> T;
fn reduce(&self, value1: T, value2: T) -> T;
}Specifies a "reduce operator". This is the combination of a start
value and a reduce function. The reduce function takes two items
and computes a reduced version. The start value S is a kind of
"zero" or "identity" value that may be intermingled as needed;
ideally, reduce(S, X) for any item X yields X.
Example: to sum up the values, use a start_value of 0 and a
reduce function of reduce(a, b) = a + b.
The order in which the reduce function will be applied is not
specified. For example, the input [ 0 1 2 ] might be reduced in a
sequential fashion:
reduce(reduce(reduce(S, 0), 1), 2)
or it might be reduced in a tree-like way:
reduce(reduce(0, 1), reduce(S, 2))
etc.
Required Methods
fn start_value(&self) -> T
fn reduce(&self, value1: T, value2: T) -> T
Implementors
impl ReduceOp<i8> for SumOpimpl ReduceOp<i16> for SumOpimpl ReduceOp<i32> for SumOpimpl ReduceOp<i64> for SumOpimpl ReduceOp<isize> for SumOpimpl ReduceOp<u8> for SumOpimpl ReduceOp<u16> for SumOpimpl ReduceOp<u32> for SumOpimpl ReduceOp<u64> for SumOpimpl ReduceOp<usize> for SumOpimpl ReduceOp<f32> for SumOpimpl ReduceOp<f64> for SumOpimpl ReduceOp<i8> for ProductOpimpl ReduceOp<i16> for ProductOpimpl ReduceOp<i32> for ProductOpimpl ReduceOp<i64> for ProductOpimpl ReduceOp<isize> for ProductOpimpl ReduceOp<u8> for ProductOpimpl ReduceOp<u16> for ProductOpimpl ReduceOp<u32> for ProductOpimpl ReduceOp<u64> for ProductOpimpl ReduceOp<usize> for ProductOpimpl ReduceOp<f32> for ProductOpimpl ReduceOp<f64> for ProductOpimpl<'r, IDENTITY, OP, ITEM> ReduceOp<ITEM> for ReduceWithIdentityOp<'r, IDENTITY, OP> where OP: Fn(ITEM, ITEM) -> ITEM + Sync,
IDENTITY: Fn() -> ITEM + Sync,
ITEM: 'r