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;
idealy, 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 SumOp
impl ReduceOp<i16> for SumOp
impl ReduceOp<i32> for SumOp
impl ReduceOp<i64> for SumOp
impl ReduceOp<isize> for SumOp
impl ReduceOp<u8> for SumOp
impl ReduceOp<u16> for SumOp
impl ReduceOp<u32> for SumOp
impl ReduceOp<u64> for SumOp
impl ReduceOp<usize> for SumOp
impl ReduceOp<f32> for SumOp
impl ReduceOp<f64> for SumOp
impl ReduceOp<i8> for MulOp
impl ReduceOp<i16> for MulOp
impl ReduceOp<i32> for MulOp
impl ReduceOp<i64> for MulOp
impl ReduceOp<isize> for MulOp
impl ReduceOp<u8> for MulOp
impl ReduceOp<u16> for MulOp
impl ReduceOp<u32> for MulOp
impl ReduceOp<u64> for MulOp
impl ReduceOp<usize> for MulOp
impl ReduceOp<f32> for MulOp
impl ReduceOp<f64> for MulOp
impl ReduceOp<i8> for MinOp
impl ReduceOp<i16> for MinOp
impl ReduceOp<i32> for MinOp
impl ReduceOp<i64> for MinOp
impl ReduceOp<isize> for MinOp
impl ReduceOp<u8> for MinOp
impl ReduceOp<u16> for MinOp
impl ReduceOp<u32> for MinOp
impl ReduceOp<u64> for MinOp
impl ReduceOp<usize> for MinOp
impl ReduceOp<f32> for MinOp
impl ReduceOp<f64> for MinOp
impl ReduceOp<i8> for MaxOp
impl ReduceOp<i16> for MaxOp
impl ReduceOp<i32> for MaxOp
impl ReduceOp<i64> for MaxOp
impl ReduceOp<isize> for MaxOp
impl ReduceOp<u8> for MaxOp
impl ReduceOp<u16> for MaxOp
impl ReduceOp<u32> for MaxOp
impl ReduceOp<u64> for MaxOp
impl ReduceOp<usize> for MaxOp
impl ReduceOp<f32> for MaxOp
impl ReduceOp<f64> for MaxOp
impl<'r, ITEM, OP> ReduceOp<Option<ITEM>> for ReduceWithOp<'r, OP> where OP: Fn(ITEM, ITEM) -> ITEM + Sync + 'r
impl<'r, ITEM, OP> ReduceOp<ITEM> for ReduceWithIdentityOp<'r, ITEM, OP> where OP: Fn(ITEM, ITEM) -> ITEM + Sync, ITEM: 'r + Clone + Sync