Trait Node

Source
pub trait Node {
    type Value: Clone;

    // Required methods
    fn initialize(value: &Self::Value) -> Self;
    fn combine(a: &Self, b: &Self) -> Self;
    fn value(&self) -> &Self::Value;
}
Expand description

Base trait required by nodes of segment trees. A type which implements this trait is essentially a “compressed” representation of a non-empty segment of values.

Required Associated Types§

Source

type Value: Clone

This type corresponds to the type of the information to create the node with Node::initialize.

Required Methods§

Source

fn initialize(value: &Self::Value) -> Self

Function to create nodes from saved value, it is assumed that even if there’s more data saved in the node, value should have enough data to create all of the data of a node of a segment segment of exactly one element.

Source

fn combine(a: &Self, b: &Self) -> Self

Function which will combine nodes a and b, where each corresponds to segments [i,j] and [j+1,k] respectively, into a node which corresponds to the segment [i,k]. This function must be associative (taking * as a symbol for combine, we have that a*(b*c)==(a*b)*c is true), but need not be commutative (it’s not necessarily true that a*b==b*a).

Source

fn value(&self) -> &Self::Value

Method which returns a reference to the current saved value.

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§

Source§

impl Node for MaxSubArraySum

Source§

impl<T> Node for LazySetWrapper<T>
where T: Node,

Source§

type Value = <T as Node>::Value

Source§

impl<T> Node for Max<T>
where T: Ord + Clone,

Source§

type Value = T

Source§

impl<T> Node for Min<T>
where T: Ord + Clone,

Source§

type Value = T

Source§

impl<T> Node for PersistentWrapper<T>
where T: Node,

Source§

type Value = <T as Node>::Value

Source§

impl<T> Node for Sum<T>
where T: Add<Output = T> + Clone,

Source§

type Value = T