pub struct TopK<T: Ord, const K: usize> { /* private fields */ }Expand description
Maintains the top K elements seen so far (by Ord), using a bounded min-heap.
Internally keeps a BinaryHeap<Reverse<T>> so peek() returns the current minimum
among the kept items.
Implementations§
Source§impl<T: Ord, const K: usize> TopK<T, K>
impl<T: Ord, const K: usize> TopK<T, K>
pub fn new() -> Self
Sourcepub fn into_sorted_iter_ascending(self) -> impl Iterator<Item = T>
pub fn into_sorted_iter_ascending(self) -> impl Iterator<Item = T>
Consumes self and returns an iterator yielding items in ascending order.
This uses BinaryHeapExtensions::into_sorted_iter, which pops from the underlying heap.
Trait Implementations§
Auto Trait Implementations§
impl<T, const K: usize> Freeze for TopK<T, K>
impl<T, const K: usize> RefUnwindSafe for TopK<T, K>
impl<T, const K: usize> Send for TopK<T, K>
impl<T, const K: usize> Sync for TopK<T, K>
impl<T, const K: usize> Unpin for TopK<T, K>
impl<T, const K: usize> UnsafeUnpin for TopK<T, K>
impl<T, const K: usize> UnwindSafe for TopK<T, K>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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