pub struct MinHeap<T, M>(/* private fields */)
where
T: Storable + PartialOrd,
M: Memory;Expand description
An implementation of the binary min heap.
Implementations§
Source§impl<T, M> MinHeap<T, M>
impl<T, M> MinHeap<T, M>
Sourcepub fn new(memory: M) -> MinHeap<T, M>
pub fn new(memory: M) -> MinHeap<T, M>
Creates a new empty heap in the specified memory, overwriting any data structures the memory might have contained.
Complexity: O(1)
Sourcepub fn init(memory: M) -> MinHeap<T, M>
pub fn init(memory: M) -> MinHeap<T, M>
Initializes a heap in the specified memory.
Complexity: O(1)
PRECONDITION: the memory is either empty or contains a valid stable heap.
Sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Removes the smallest item from the heap and returns it.
Returns None if the heap is empty.
Complexity: O(log(self.len()))
Sourcepub fn peek(&self) -> Option<T>
pub fn peek(&self) -> Option<T>
Returns the smallest item in the heap.
Returns None if the heap is empty.
Complexity: O(1)
Sourcepub fn iter(&self) -> impl Iterator<Item = T>
pub fn iter(&self) -> impl Iterator<Item = T>
Returns an iterator visiting all values in the underlying vector, in arbitrary order.
Sourcepub fn into_memory(self) -> M
pub fn into_memory(self) -> M
Returns the underlying memory instance.
Trait Implementations§
Auto Trait Implementations§
impl<T, M> Freeze for MinHeap<T, M>where
M: Freeze,
impl<T, M> RefUnwindSafe for MinHeap<T, M>where
M: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, M> Send for MinHeap<T, M>
impl<T, M> Sync for MinHeap<T, M>
impl<T, M> Unpin for MinHeap<T, M>
impl<T, M> UnwindSafe for MinHeap<T, M>where
M: UnwindSafe,
T: UnwindSafe,
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