Trait segment_tree::ops::Operation
source · pub trait Operation<N> {
fn combine(&self, a: &N, b: &N) -> N;
fn combine_mut(&self, a: &mut N, b: &N) { ... }
fn combine_mut2(&self, a: &N, b: &mut N) { ... }
fn combine_left(&self, a: N, b: &N) -> N { ... }
fn combine_right(&self, a: &N, b: N) -> N { ... }
fn combine_both(&self, a: N, b: N) -> N { ... }
}
Expand description
A trait that specifies which associative operator to use in a segment tree.
Required Methods§
sourcefn combine(&self, a: &N, b: &N) -> N
fn combine(&self, 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§
sourcefn combine_mut(&self, a: &mut N, b: &N)
fn combine_mut(&self, 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
.
sourcefn combine_mut2(&self, a: &N, b: &mut N)
fn combine_mut2(&self, a: &N, b: &mut N)
Replace the value in b
with combine(a, b)
. This function exists to allow
certain optimizations and by default simply calls combine
.
sourcefn combine_left(&self, a: N, b: &N) -> N
fn combine_left(&self, 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
.
sourcefn combine_right(&self, a: &N, b: N) -> N
fn combine_right(&self, 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
.
sourcefn combine_both(&self, a: N, b: N) -> N
fn combine_both(&self, 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
.