Trait segment_tree::ops::Operation
[−]
[src]
pub trait Operation<N> { fn combine(a: &N, b: &N) -> N; fn combine_mut(a: &mut N, b: &N) { ... } fn combine_mut2(a: &N, b: &mut N) { ... } fn combine_left(a: N, b: &N) -> N { ... } fn combine_right(a: &N, b: N) -> N { ... } fn combine_both(a: N, b: N) -> N { ... } }
A trait that specifies which associative operator to use in a segment tree.
Required Methods
fn combine(a: &N, b: &N) -> N
The operation that is performed to combine two intervals in the segment tree.
This function must be associative, that is combine(combine(a, b), c) = combine(a, combine(b, c))
.
Provided Methods
fn combine_mut(a: &mut N, b: &N)
Replace the value in a with combine(a, b)
. This function exists to allow certain
optimizations and by default simply calls combine
.
fn combine_mut2(a: &N, b: &mut N)
Replace the value in a with combine(a, b)
. This function exists to allow certain
optimizations and by default simply calls combine
.
fn combine_left(a: N, b: &N) -> N
Must return the same as combine
. This function exists to allow certain optimizations
and by default simply calls combine_mut
.
fn combine_right(a: &N, b: N) -> N
Must return the same as combine
. This function exists to allow certain optimizations
and by default simply calls combine_mut2
.
fn combine_both(a: N, b: N) -> N
Must return the same as combine
. This function exists to allow certain optimizations
and by default simply calls combine_left
.
Implementors
impl<T: Add<Output = T> + Copy> Operation<T> for Add
impl<T: Mul<Output = T> + Copy> Operation<T> for Mul
impl<T: BitXor<Output = T> + Copy> Operation<T> for Xor
impl<T: BitAnd<Output = T> + Copy> Operation<T> for And
impl<T: BitOr<Output = T> + Copy> Operation<T> for Or
impl<T: Ord + Copy> Operation<T> for Max
impl Operation<f32> for MaxIgnoreNaN
impl Operation<f64> for MaxIgnoreNaN
impl Operation<f32> for MaxTakeNaN
impl Operation<f64> for MaxTakeNaN
impl<T: Ord + Copy> Operation<T> for Min
impl Operation<f32> for MinIgnoreNaN
impl Operation<f64> for MinIgnoreNaN
impl Operation<f32> for MinTakeNaN
impl Operation<f64> for MinTakeNaN
impl<TA, TB, A: Operation<TA>, B: Operation<TB>> Operation<(TA, TB)> for Pair<A, B>
impl<TA: Clone, A: Operation<TA>> Operation<Option<TA>> for WithIdentity<A>