Struct priority_queue::PriorityQueue [] [src]

pub struct PriorityQueue<I, P> where
    I: Hash + Eq
{ /* fields omitted */ }

A priority queue with efficient change function to change the priority of an element.

The priority is of type P, that must implement std::cmp::Ord. The item is of typer I, that must implement Hash and Eq Implemented as an heap of indexes, stores the items inside an OrderMap to be able to retrieve them quickly.

Methods

impl<I, P> PriorityQueue<I, P> where
    P: Ord,
    I: Hash + Eq
[src]

Creates an empty PriorityQueue

Creates an empty PriorityQueue with the specified capacity.

The internal collections will be able to hold at least capacity elements without reallocating. If capacity is 0, there will no allocation.

Returns the number of elements the internal map can hold without reallocating.

This number is a lower bound; the map might be able to hold more, but is guaranteed to be able to hold at least this many.

Shrinks the capacity of the internal data structures that support this operation as much as possible.

Returns the number of elements in the priority queue.

Returns true if the priority queue contains no elements.

Insert they item-priority pair into the queue.

If item was already into the queue, the old value of its priority is returned in Some; otherwise, return None.

Computes in O(log(N)) time.

Returns the couple (item, priority) with the greatest priority in the queue, or None if it is empty.

Computes in O(1) time

Returns the couple (item, priority) with the greatest priority in the queue, or None if it is empty.

The item is a mutable reference, but it's a logic error to modify it in a way that change the result of Hash or Eq.

The priority cannot be modified with a call to this function. To modify the priority use ...

Computes in O(1) time

Trait Implementations

impl<I: Clone, P: Clone> Clone for PriorityQueue<I, P> where
    I: Hash + Eq
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<I: Debug, P: Debug> Debug for PriorityQueue<I, P> where
    I: Hash + Eq
[src]

Formats the value using the given formatter.