[src]

Struct collections::priority_queue::PriorityQueue

pub struct PriorityQueue<T> {
    // some fields omitted
}

A priority queue implemented with a binary heap

Methods

impl<T: Ord> PriorityQueue<T>

fn iter<'a>(&'a self) -> Items<'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) -> Option<&'a T>

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_exact(&mut self, n: uint)

Reserve capacity for exactly n elements in the PriorityQueue. Do nothing if the capacity is already sufficient.

fn reserve(&mut self, n: uint)

Reserve capacity for at least n elements in the PriorityQueue. Do nothing if the capacity is already sufficient.

fn pop(&mut self) -> T

Pop the greatest item from the queue - fails if empty

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

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: Ord> Container for PriorityQueue<T>

fn len(&self) -> uint

Returns the length of the queue

impl<T: Ord> Mutable for PriorityQueue<T>

fn clear(&mut self)

Drop all items from the queue

impl<T: Ord> FromIterator<T> for PriorityQueue<T>

fn from_iter<Iter: Iterator<T>>(iter: Iter) -> PriorityQueue<T>

impl<T: Ord> Extendable<T> for PriorityQueue<T>

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

Derived Implementations

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

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