pub trait LazySegTreeSpec {
type T: Clone;
type U: Clone;
const ID: Self::T;
// Required methods
fn op_on_data(d1: &mut Self::T, d2: &Self::T);
fn op_on_update(u1: &mut Self::U, u2: &Self::U);
fn op_update_on_data(u: &Self::U, d: &mut Self::T, size: usize);
}Expand description
Specification trait for LazySegTree.
Implement this trait to define the concrete behavior of the tree:
T: data stored in nodes (the aggregate type),U: lazy-update type (the tag type),ID: identity element forT.
Required operations:
op_on_data— combine twoTs into one (e.g., sum or min),op_on_update— compose two updatesUinto a single update,op_update_on_data— apply an updateUtoTrepresentingsizeleaves.
Required Associated Constants§
Required Associated Types§
Required Methods§
Sourcefn op_on_data(d1: &mut Self::T, d2: &Self::T)
fn op_on_data(d1: &mut Self::T, d2: &Self::T)
Combine two child values into a parent value, performed in-place.
This operation must be associative. Mutates d1 to be the result of combining
d1 with d2. For example, for range sum queries: *d1 += *d2.
Sourcefn op_on_update(u1: &mut Self::U, u2: &Self::U)
fn op_on_update(u1: &mut Self::U, u2: &Self::U)
Compose two updates, performed in-place.
If update u1 is applied before u2, then the composed update should be
the result of op_on_update(u1, u2). This operation must be associative.
Mutates u1 to be the result of the composition.
Sourcefn op_update_on_data(u: &Self::U, d: &mut Self::T, size: usize)
fn op_update_on_data(u: &Self::U, d: &mut Self::T, size: usize)
Apply an update u to a node’s stored aggregate d which represents size leaves.
This operation is performed in-place and mutates d to be the result.
For example, for range-add + range-sum: *d += u * size.
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.