A priority queue implemented with a binary heap
PriorityQueue
pub struct PriorityQueue <T: Ord>{
priv data: ~[T],
}
PriorityQueue<T>
top
fn top() -> &self /T
Returns the greatest item in the queue - fails if empty
maybe_top
fn maybe_top() -> Option<&self /T>
Returns the greatest item in the queue - None if empty
len
fn len() -> uint
Returns the length of the queue
is_empty
fn is_empty() -> bool
Returns true if a queue contains no elements
is_not_empty
fn is_not_empty() -> bool
Returns true if a queue contains some elements
capacity
fn capacity() -> uint
Returns the number of elements the queue can hold without reallocating
reserve
fn reserve(n: uint)
reserve_at_least
fn reserve_at_least(n: uint)
clear
fn clear()
Drop all items from the queue
pop
fn pop() -> T
Pop the greatest item from the queue - fails if empty
maybe_pop
fn maybe_pop() -> Option<T>
Pop the greatest item from the queue - None if empty
push
fn push(item: T)
Push an item onto the queue
push_pop
fn push_pop(item: T) -> T
Optimized version of a push followed by a pop
replace
fn replace(item: T) -> T
Optimized version of a pop followed by a push - fails if empty
to_vec
fn to_vec() -> ~[T]
Consume the PriorityQueue and return the underlying vector
to_sorted_vec
fn to_sorted_vec() -> ~[T]
Consume the PriorityQueue and return a vector in sorted (ascending) order
new
fn new() -> PriorityQueue<T>
Create an empty PriorityQueue
from_vec
fn from_vec(xs: ~[T]) -> PriorityQueue<T>
Create a PriorityQueue from a vector (heapify)
siftup
fn siftup(start: uint, pos: uint)
siftdown_range
fn siftdown_range(pos: uint, end: uint)
siftdown
fn siftdown(pos: uint)