Struct seg_tree::segment_tree::SegmentTree
source · [−]Expand description
Segment tree with range queries and point updates.
It uses O(n)
space, assuming that each node uses O(1)
space.
Note if you need to use lower_bound
, just use the RecursiveSegmentTree it uses double the memory though and it’s less performant.
Implementations
sourceimpl<T> SegmentTree<T> where
T: Node + Clone,
impl<T> SegmentTree<T> where
T: Node + Clone,
sourcepub fn build(values: &[T]) -> Self
pub fn build(values: &[T]) -> Self
Builds 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.
Auto Trait Implementations
impl<T> RefUnwindSafe for SegmentTree<T> where
T: RefUnwindSafe,
impl<T> Send for SegmentTree<T> where
T: Send,
impl<T> Sync for SegmentTree<T> where
T: Sync,
impl<T> Unpin for SegmentTree<T> where
T: Unpin,
impl<T> UnwindSafe for SegmentTree<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more