pub struct Sum<T> where
    T: Add<Output = T> + Clone
{ /* private fields */ }
Expand description

Implementation of range sum for generic type T, it implements Node and LazyNode, as such it can be used as a node in every segment tree type.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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.

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.

The node is initialized with the value given.

As this is a range sum node, the operation which is used to ‘merge’ two nodes is +.

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

Method which returns a reference to the current saved value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.