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.

Implementations on Foreign Types§

source§

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

§

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>where K: Clone, V: PartialOrd + Clone, ID: FromPrimitive + ToPrimitive + Copy + Eq,

§

type Item = ID