Function fenwick::array::prefix_sum [] [src]

pub fn prefix_sum<T>(fenwick: &[T], i: usize) -> T where
    T: AddAssign + Copy + Default

Calculates the prefix sum up to and including i in the Fenwick tree stored in a borrowed slice (zero-based).

Conceptually calculates a[0] + ... + a[i] on the original array a.

Panics

Panics if fenwick[i] is out of bound.

Examples

See module-level example.