Struct extra::priority_queue::PriorityQueue

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

A priority queue implemented with a binary heap

Methods

impl<T: std::cmp::Ord> PriorityQueue<T>

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

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

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

Returns the greatest item in the queue - fails if empty

fn maybe_top<'a>(&'a self) -> std::option::Option

Returns the greatest item in the queue - None if empty

fn capacity(&self) -> uint

Returns the number of elements the queue can hold without reallocating

fn reserve(&mut self, n: uint)

fn reserve_at_least(&mut self, n: uint)

fn pop(&mut self) -> T

Pop the greatest item from the queue - fails if empty

fn maybe_pop(&mut self) -> std::option::Option

Pop the greatest item from the queue - None if empty

fn push(&mut self, item: T)

Push an item onto the queue

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

Optimized version of a push followed by a pop

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

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

fn to_vec(self) -> ~[T]

Consume the PriorityQueue and return the underlying vector

fn to_sorted_vec(self) -> ~[T]

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

fn new() -> PriorityQueue<T>

Create an empty PriorityQueue

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

Create a PriorityQueue from a vector (heapify)

Trait Implementations

impl<T: std::clone::Clone> std::clone::Clone for PriorityQueue<T>

fn clone(&self) -> PriorityQueue<T>

impl<T: std::cmp::Ord> std::container::Container for PriorityQueue<T>

fn len(&self) -> uint

Returns the length of the queue

impl<T: std::cmp::Ord> std::container::Mutable for PriorityQueue<T>

fn clear(&mut self)

Drop all items from the queue

impl<T: std::cmp::Ord> std::iter::FromIterator for PriorityQueue<T>

fn from_iterator<Iter: std::iter::Iterator>(iter: &mut Iter) -> PriorityQueue<T>

impl<T: std::cmp::Ord> std::iter::Extendable for PriorityQueue<T>

fn extend<Iter: std::iter::Iterator>(&mut self, iter: &mut Iter)