logo
pub struct FenwickTree<T: Default + Ord, Op: PrefixOp<T>> { /* private fields */ }
Expand description

In a max bit tree or Fenwick Tree, get(i) will return the largest element e that has been added to the bit tree with set(j, e), where j <= i. Initially all positions have the value T::default(). Note that a set cannot be ‘undone’ by inserting a smaller element at the same index. Time Complexity: O(n) to build a new tree or O(log n) for get() and set() operations, where n = tree.len().

Implementations

Create a new bit tree with len elements

Returns the largest element e that has been added to the bit tree with set(j, e), where j <= i.

Set the value val at position idx; val will be returned for any get(j) where j >= idx, if it is the maximum value inserted between 0 and j. Inserting a value val2 after inserting val1 where val1 > val2 will have no effect.

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

Performs the conversion.

Performs the conversion.

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

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.