pub trait Operation<N> {
// Required method
fn combine(&self, a: &N, b: &N) -> N;
// Provided methods
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.