pub trait SegTreeSpec {
type T: Clone;
const ID: Self::T;
// Required method
fn op(a: &mut Self::T, b: &Self::T);
}
Expand description
Specification for segment tree operations.
Defines an associative operation (monoid) with identity element.
Must satisfy: op(a, ID) = a
and op(a, op(b, c)) = op(op(a, b), c)
.
§Example
use array_range_query::SegTreeSpec;
struct SumSpec;
impl SegTreeSpec for SumSpec {
type T = i32;
const ID: Self::T = 0;
fn op(a: &mut Self::T, b: &Self::T) { *a += *b; }
}
Required Associated Constants§
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.