pub struct PersistentSegmentTree<T: PersistentNode> { /* private fields */ }
Expand description

Persistent segment tree, it saves every version of itself, it has range queries and point updates. It uses O(n+q*log(n)) space, where q is the amount of updates, and assuming that each node uses O(1) space.

Implementations

Builds persistent segment tree from slice, each element of the slice will correspond to a leaf of the segment tree. It has time complexity of O(n*log(n)), assuming that combine has constant time complexity.

Returns the result from the range [left,right] from the version of the segment tree. It returns None if and only if range is empty. It will panic if left or right are not in [0,n), or if version is not in [0,versions). It has time complexity of O(log(n)), assuming that combine has constant time complexity.

Creates a new segment tree version from version were the p-th element of the segment tree to value T and update the segment tree correspondingly. It will panic if p is not in [0,n), or if version is not in [0,versions). It has time complexity of O(log(n)), assuming that combine has constant time complexity.

Return the amount of different versions the current segment tree has.

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.

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.