pub struct MinHeap<T: Ord>(pub Vec<T>);
Expand description
A very simple min heap implementation
Tuple Fields§
§0: Vec<T>
Trait Implementations§
Source§impl<T: Ord> Heap<T> for MinHeap<T>
impl<T: Ord> Heap<T> for MinHeap<T>
Source§fn less(&self, i: usize, j: usize) -> bool
fn less(&self, i: usize, j: usize) -> bool
Compares two elements of the heap at i and j index
It is guaranteed that the i and j are always valid
Source§fn swap(&mut self, i: usize, j: usize)
fn swap(&mut self, i: usize, j: usize)
This function must swap the i and j element in the heap array
It is guaranteed that the i and j are always valid
Source§fn push(&mut self, x: T)
fn push(&mut self, x: T)
push is just like push in vector. It should add x to the last of array
Auto Trait Implementations§
impl<T> Freeze for MinHeap<T>
impl<T> RefUnwindSafe for MinHeap<T>where
T: RefUnwindSafe,
impl<T> Send for MinHeap<T>where
T: Send,
impl<T> Sync for MinHeap<T>where
T: Sync,
impl<T> Unpin for MinHeap<T>where
T: Unpin,
impl<T> UnwindSafe for MinHeap<T>where
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