A priority queue implemented with a binary heap

Struct PriorityQueue

pub struct PriorityQueue<T> {
    priv data: ~[T],
}

A priority queue implemented with a binary heap

Struct PriorityQueueIterator

pub struct PriorityQueueIterator<'self, T> {
    priv iter: vec::VecIterator<'self, T>,
}

PriorityQueue iterator

Implementation of Container for PriorityQueue<T> where <T: Ord>

Method len

fn len(&self) -> uint

Returns the length of the queue

Method is_empty

fn is_empty(&self) -> bool

Returns true if a queue contains no elements

Implementation of Mutable for PriorityQueue<T> where <T: Ord>

Method clear

fn clear(&mut self)

Drop all items from the queue

Implementation for PriorityQueue<T> where <T: Ord>

Method iter

fn iter<'a>(&'a self) -> PriorityQueueIterator<'a, T>

An iterator visiting all values in underlying vector, in arbitrary order.

Method top

fn top<'a>(&'a self) -> &'a T

Returns the greatest item in the queue - fails if empty

Method maybe_top

fn maybe_top<'a>(&'a self) -> Option<&'a T>

Returns the greatest item in the queue - None if empty

Method capacity

fn capacity(&self) -> uint

Returns the number of elements the queue can hold without reallocating

Method reserve

fn reserve(&mut self, n: uint)

Method reserve_at_least

fn reserve_at_least(&mut self, n: uint)

Method pop

fn pop(&mut self) -> T

Pop the greatest item from the queue - fails if empty

Method maybe_pop

fn maybe_pop(&mut self) -> Option<T>

Pop the greatest item from the queue - None if empty

Method push

fn push(&mut self, item: T)

Push an item onto the queue

Method push_pop

fn push_pop(&mut self, mut item: T) -> T

Optimized version of a push followed by a pop

Method replace

fn replace(&mut self, mut item: T) -> T

Optimized version of a pop followed by a push - fails if empty

Method to_vec

fn to_vec(self) -> ~[T]

Consume the PriorityQueue and return the underlying vector

Method to_sorted_vec

fn to_sorted_vec(self) -> ~[T]

Consume the PriorityQueue and return a vector in sorted (ascending) order

Method new

fn new() -> PriorityQueue<T>

Create an empty PriorityQueue

Method from_vec

fn from_vec(xs: ~[T]) -> PriorityQueue<T>

Create a PriorityQueue from a vector (heapify)

Implementation of Iterator<&'self T> for PriorityQueueIterator<'self, T> where <'self, T>

Method next

fn next(&mut self) -> Option<&'self T>