Struct binomial_heap::BinomialHeap [] [src]

pub struct BinomialHeap<T: Ord> { /* fields omitted */ }

A priority queue based on a binomial heap.

Like BinaryHeap, BionmialHeap is an implementation of a priority queue. Unlike BinaryHeap, BionmialHeap provides an efficient append method, at the cost of greater memory usage, slower iteration, and poor cache locality.

Time Complexity

Operation Time Complexity
append O(log n) (amortized)
peek O(log n)
pop O(log n)
push O(1) (amortized)
push_pop O(log n)
replace O(log n)

Methods

impl<T: Ord> BinomialHeap<T>
[src]

Returns a new heap.

Checks if the heap is empty.

Returns the number of items in the heap.

Returns an iterator that yields references to the items in the heap in arbitrary order.

Returns a reference to the greatest item in the heap.

Returns None if the heap is empty.

Pushes the given item onto the heap.

Moves the given heap's items into the heap, leaving the given heap empty.

This is equivalent to, but likely to be faster than, the following:

heap.extend(heap2.drain());

Pushes the given item onto the heap, then removes the greatest item in the heap and returns it.

This method is equivalent to, but likely faster than, the following:

heap.push(item);
let max = heap.pop().unwrap();

Removes the greatest item in the heap, then pushes the given item onto the heap.

Returns the item that was removed, or None if the heap was empty.

This method is equivalent to, but likely faster than, the following:

let max = heap.pop();
heap.push(item);

Removes the greatest item in the heap and returns it.

Returns None if the heap was empty.

If a call to this method is immediately preceded by a call to push, consider using push_pop instead. If a call to this method is immediately followed by a call to push, consider using replace instead.

Removes all items from the heap.

Removes all items from the heap and returns an iterator that yields them in arbitrary order.

All items are removed even if the iterator is not exhausted. However, the behavior of this method is unspecified if the iterator is leaked (e.g. via mem::forget).

Trait Implementations

impl<T: Clone + Ord> Clone for BinomialHeap<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Ord + Debug> Debug for BinomialHeap<T>
[src]

Formats the value using the given formatter.

impl<T: Ord> Default for BinomialHeap<T>
[src]

Returns the "default value" for a type. Read more

impl<T: Ord> Extend<T> for BinomialHeap<T>
[src]

Extends a collection with the contents of an iterator. Read more

impl<'a, T: 'a + Ord + Copy> Extend<&'a T> for BinomialHeap<T>
[src]

Extends a collection with the contents of an iterator. Read more

impl<T: Ord> FromIterator<T> for BinomialHeap<T>
[src]

Creates a value from an iterator. Read more

impl<'a, T: 'a + Ord + Copy> FromIterator<&'a T> for BinomialHeap<T>
[src]

Creates a value from an iterator. Read more

impl<T: Ord> IntoIterator for BinomialHeap<T>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

impl<'a, T: Ord> IntoIterator for &'a BinomialHeap<T>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more