Skip to main content

NodeInfo

Trait NodeInfo 

pub trait NodeInfo: Clone {
    type L: Leaf;

    // Required methods
    fn accumulate(&mut self, other: &Self);
    fn compute_info(_: &Self::L) -> Self;

    // Provided methods
    fn identity() -> Self { ... }
    fn interval(&self, len: usize) -> Interval { ... }
}

Required Associated Types§

type L: Leaf

The type of the leaf.

A given NodeInfo is for exactly one type of leaf. That is why the leaf type is an associated type rather than a type parameter.

Required Methods§

fn accumulate(&mut self, other: &Self)

An operator that combines info from two subtrees. It is intended (but not strictly enforced) that this operator be associative and obey an identity property. In mathematical terms, the accumulate method is the operation of a monoid.

fn compute_info(_: &Self::L) -> Self

A mapping from a leaf into the info type. It is intended (but not strictly enforced) that applying the accumulate method to the info derived from two leaves gives the same result as deriving the info from the concatenation of the two leaves. In mathematical terms, the compute_info method is a monoid homomorphism.

Provided Methods§

fn identity() -> Self

The identity of the monoid. Need not be implemented because it can be computed from the leaf default.

This is here to demonstrate that this is a monoid.

fn interval(&self, len: usize) -> Interval

The interval covered by the first len base units of this node. The default impl is sufficient for most types, but interval trees may need to override it.

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§

§

impl NodeInfo for BreaksInfo

§

impl NodeInfo for RopeInfo

§

type L = String

§

impl<T> NodeInfo for SpansInfo<T>
where T: Clone,

§

type L = SpansLeaf<T>