Struct leonardo_heap::LeonardoHeap
[−]
[src]
pub struct LeonardoHeap<T> { /* fields omitted */ }
Methods
impl<T: Ord + Debug> LeonardoHeap<T>
[src]
fn new() -> Self
Creates a new, empty LeonardoHeap<T>
fn with_capacity(capacity: usize) -> Self
Creates a new LeonardoHeap<T>
with space allocated for at least
capacity
elements.
fn capacity(&self) -> usize
Returns the number of elements for which space has been allocated.
fn reserve(&mut self, additional: usize)
Reserve at least enough space for additional
elements to be pushed
on to the heap.
fn reserve_exact(&mut self, additional: usize)
Reserves the minimum capacity for exactly additional
elements to be
pushed onto the heap.
fn shrink_to_fit(&mut self)
Shrinks the capacity of the underlying storage to free up as much space as possible.
fn retain<F>(&mut self, f: F) where
F: FnMut(&T) -> bool,
F: FnMut(&T) -> bool,
Removes all elements from the heap that do not match a predicate.
fn clear(&mut self)
Removes all elements from the heap.
fn len(&self) -> usize
Returns the number of elements in the heap.
fn is_empty(&self) -> bool
Returns true
if the heap contains no elements, false
otherwise.
fn dedup(&mut self)
Removes duplicate elements from the heap, preserving heap order.
fn sort(&mut self)
Forces sorting of the entire underlying array. The sorted array is still a valid leonardo heap.
fn push(&mut self, item: T)
Adds a new element to the heap. The heap will be rebalanced to maintain the string and heap properties.
Elements pushed more than once will not be deduplicated.
fn peek(&self) -> Option<&T>
Returns a reference to the largest element in the heap without removing it.
fn pop(&mut self) -> Option<T>
Removes and returns the largest element in the heap. If the heap is
empty, returns None
.
fn iter(&mut self) -> Iter<T>
Returns a sorted iterator over the elements in the heap.
Will lazily sort the top elements of the heap in-place as it is consumed.
fn drain(&mut self) -> Drain<T>
Returns an iterator that removes and returns elements from the top of the heap.