pub struct SumTree { /* private fields */ }Expand description
Binary sum-tree for O(log N) prefix-sum queries.
Internally stores 2 * capacity nodes where leaves occupy indices
[capacity .. 2*capacity) and internal nodes hold partial sums.
Implementations§
Source§impl SumTree
impl SumTree
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a sum-tree with capacity leaves, all initialised to zero.
The capacity is rounded up to the next power of two for efficient
binary-tree indexing. Unused leaves beyond the logical capacity
hold priority 0.0 (sum-tree) and f64::INFINITY (min-tree).
The min() method may therefore return INFINITY when the buffer
is not full; callers should handle this (see PrioritizedReplayBuffer::tree_min_prob).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SumTree
impl RefUnwindSafe for SumTree
impl Send for SumTree
impl Sync for SumTree
impl Unpin for SumTree
impl UnwindSafe for SumTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more