A priority queue implemented with a binary heap

Struct PriorityQueue

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

Implementation for PriorityQueue<T>

Method top

fn top() -> &self /T

Returns the greatest item in the queue - fails if empty

Method maybe_top

fn maybe_top() -> Option<&self /T>

Returns the greatest item in the queue - None if empty

Method len

fn len() -> uint

Returns the length of the queue

Method is_empty

fn is_empty() -> bool

Returns true if a queue contains no elements

Method is_not_empty

fn is_not_empty() -> bool

Returns true if a queue contains some elements

Method capacity

fn capacity() -> uint

Returns the number of elements the queue can hold without reallocating

Method reserve

fn reserve(n: uint)

Method reserve_at_least

fn reserve_at_least(n: uint)

Method clear

fn clear()

Drop all items from the queue

Method pop

fn pop() -> T

Pop the greatest item from the queue - fails if empty

Method maybe_pop

fn maybe_pop() -> Option<T>

Pop the greatest item from the queue - None if empty

Method push

fn push(item: T)

Push an item onto the queue

Method push_pop

fn push_pop(item: T) -> T

Optimized version of a push followed by a pop

Method replace

fn replace(item: T) -> T

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

Method to_vec

fn to_vec() -> ~[T]

Consume the PriorityQueue and return the underlying vector

Method to_sorted_vec

fn to_sorted_vec() -> ~[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)

Method siftup

fn siftup(start: uint, pos: uint)

Method siftdown_range

fn siftdown_range(pos: uint, end: uint)

Method siftdown

fn siftdown(pos: uint)