SegTreeSpec

Trait SegTreeSpec 

Source
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§

Source

const ID: Self::T

Identity element for the operation.

Required Associated Types§

Source

type T: Clone

Element type stored in the segment tree.

Required Methods§

Source

fn op(a: &mut Self::T, b: &Self::T)

Associative binary operation, performed in-place.

Modifies a to store the result of combining a with b.

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.

Implementors§