A priority queue implemented with a binary heap
PriorityQueue
- A priority queue implemented with a binary heapPriorityQueueIterator
- PriorityQueue iteratorof Container for PriorityQueue<T> where <T: Ord>
of Mutable for PriorityQueue<T> where <T: Ord>
for PriorityQueue<T> where <T: Ord>
of Iterator<&'self T> for PriorityQueueIterator<'self, T> where <'self, T>
PriorityQueue
pub struct PriorityQueue<T> {
priv data: ~[T],
}
A priority queue implemented with a binary heap
PriorityQueueIterator
pub struct PriorityQueueIterator<'self, T> {
priv iter: vec::VecIterator<'self, T>,
}
PriorityQueue iterator
Container
for PriorityQueue<T>
where <T: Ord>
len
fn len(&self) -> uint
Returns the length of the queue
is_empty
fn is_empty(&self) -> bool
Returns true if a queue contains no elements
Mutable
for PriorityQueue<T>
where <T: Ord>
clear
fn clear(&mut self)
Drop all items from the queue
PriorityQueue<T>
where <T: Ord>
iter
fn iter<'a>(&'a self) -> PriorityQueueIterator<'a, T>
An iterator visiting all values in underlying vector, in arbitrary order.
top
fn top<'a>(&'a self) -> &'a T
Returns the greatest item in the queue - fails if empty
maybe_top
fn maybe_top<'a>(&'a self) -> Option<&'a T>
Returns the greatest item in the queue - None if empty
capacity
fn capacity(&self) -> uint
Returns the number of elements the queue can hold without reallocating
reserve
fn reserve(&mut self, n: uint)
reserve_at_least
fn reserve_at_least(&mut self, n: uint)
pop
fn pop(&mut self) -> T
Pop the greatest item from the queue - fails if empty
maybe_pop
fn maybe_pop(&mut self) -> Option<T>
Pop the greatest item from the queue - None if empty
push
fn push(&mut self, item: T)
Push an item onto the queue
push_pop
fn push_pop(&mut self, mut item: T) -> T
Optimized version of a push followed by a pop
replace
fn replace(&mut self, mut item: T) -> T
Optimized version of a pop followed by a push - fails if empty
to_vec
fn to_vec(self) -> ~[T]
Consume the PriorityQueue and return the underlying vector
to_sorted_vec
fn to_sorted_vec(self) -> ~[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)
Iterator<&'self T>
for PriorityQueueIterator<'self, T>
where <'self, T>
next
fn next(&mut self) -> Option<&'self T>