pub trait LazyNode: Node {
    fn lazy_update(&mut self, i: usize, j: usize);
    fn update_lazy_value(&mut self, new_value: &<Self as Node>::Value);
    fn lazy_value(&self) -> Option<&<Self as Node>::Value>;
}
Expand description

Required trait by nodes of lazy segment trees. It’s defined as an interface for the operations needed on the lazy_value. It is recommended to implement it using an Option type. See Implementators for some example implementations

Required Methods

The following invariant must be met while implementing this method, if lazy_value is called immediately after this function then it must return None. (See Option::take)

The following invariant must be met while implementing this method, if lazy_value is called immediately after this function then it must return Some(&value).

Must return a reference to the current lazy value only if it exists.

Implementors

Implementation for maximum range query, the update sets each item in the range to the given value.

Implementation for minimum range query, the update sets each item in the range to the given value.

Implementation for sum range query node, the update adds the value to each item in the range. It assumes that a*n, where a: T and n: usize is well defined and a*n = a+...+a with ‘n’ a. For non-commutative operations, two things will be true lazy_value = lazy_value + new_value.