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