seg_tree/nodes/
lazy_node.rs

1use super::Node;
2
3/// Required trait by nodes of lazy segment trees.
4/// It's defined as an interface for the operations needed on the `lazy_value`.
5/// It is recommended to implement it using an Option type.
6/// See [Implementors](LazyNode#implementors) for some example implementations.
7pub trait LazyNode: Node {
8    /// 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`])
9    fn lazy_update(&mut self, i: usize, j: usize);
10    /// 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)`.
11    fn update_lazy_value(&mut self, new_value: &<Self as Node>::Value);
12    /// Must return a reference to the current lazy value only if it exists.
13    fn lazy_value(&self) -> Option<&<Self as Node>::Value>;
14}