Skip to main content

ItemPriQueue

Trait ItemPriQueue 

Source
pub trait ItemPriQueue<K, V> {
    type Item;

    // Required methods
    fn is_empty(&self) -> bool;
    fn clear(&mut self);
    fn push(&mut self, key: K, value: V) -> Self::Item;
    fn decrease_key(&mut self, item: &mut Self::Item, value: V) -> bool;
    fn pop_min(&mut self) -> Option<(K, V)>;
    fn value(&self, item: &Self::Item) -> &V;
}

Required Associated Types§

Source

type Item

Handle for an item in the queue.

Required Methods§

Source

fn is_empty(&self) -> bool

Return true iff the queue contains no element.

Source

fn clear(&mut self)

Remove all elements from the queue.

Source

fn push(&mut self, key: K, value: V) -> Self::Item

Push the element with given key and value onto the queue.

Return a handle referencing the element. That handle can be used in a subsequent call to decrease_key.

Source

fn decrease_key(&mut self, item: &mut Self::Item, value: V) -> bool

Decrease the value of some item in the queue.

Returns true if the new value is smaller than the old one.

Source

fn pop_min(&mut self) -> Option<(K, V)>

Remove and return the element with the smallest value from the queue or None if the queue is empty.

Source

fn value(&self, item: &Self::Item) -> &V

Return the current value associated with some item in the queue.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'a, P, K, V> ItemPriQueue<K, V> for &'a mut P
where P: ItemPriQueue<K, V>,

Source§

type Item = <P as ItemPriQueue<K, V>>::Item

Source§

fn is_empty(&self) -> bool

Source§

fn clear(&mut self)

Source§

fn push(&mut self, key: K, value: V) -> Self::Item

Source§

fn decrease_key(&mut self, item: &mut Self::Item, value: V) -> bool

Source§

fn pop_min(&mut self) -> Option<(K, V)>

Source§

fn value(&self, item: &Self::Item) -> &V

Implementors§

Source§

impl<K, V, ID> ItemPriQueue<K, V> for BinHeap<K, V, ID>

Source§

type Item = ID