pub struct PriorityQueue<K, T>(/* private fields */)
where
K: Ord;
Expand description
A utility type implementing a queue which can be used to automatically sort data by its time in ascending order.
Note that the performance of this queue is very relevant to overall algorithm performance of many graph-walking algorithms, and as it stands our implementation is about 6% slower in practice, probably also depending on the size of the stored data.
Implementations§
Source§impl<K, T> PriorityQueue<K, T>where
K: Ord,
impl<K, T> PriorityQueue<K, T>where
K: Ord,
Sourcepub fn new() -> PriorityQueue<K, T>
pub fn new() -> PriorityQueue<K, T>
Create a new instance.
Sourcepub fn insert(&mut self, key: K, value: T)
pub fn insert(&mut self, key: K, value: T)
Insert value
so that it is ordered according to key
.
Sourcepub fn pop(&mut self) -> Option<(K, T)>
pub fn pop(&mut self) -> Option<(K, T)>
Pop the highest-priority item key and value off the queue.
Sourcepub fn iter_unordered(&self) -> impl Iterator<Item = &T>
pub fn iter_unordered(&self) -> impl Iterator<Item = &T>
Iterate all items ordered from highest to lowest priority.
Sourcepub fn into_iter_unordered(self) -> impl Iterator<Item = (K, T)>
pub fn into_iter_unordered(self) -> impl Iterator<Item = (K, T)>
Turn this instance into an iterator over its keys and values in arbitrary order.
Trait Implementations§
Source§impl<K, T> Clone for PriorityQueue<K, T>
impl<K, T> Clone for PriorityQueue<K, T>
Source§fn clone(&self) -> PriorityQueue<K, T>
fn clone(&self) -> PriorityQueue<K, T>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<K, T> Debug for PriorityQueue<K, T>
impl<K, T> Debug for PriorityQueue<K, T>
Source§impl<K, T> Default for PriorityQueue<K, T>
impl<K, T> Default for PriorityQueue<K, T>
Source§fn default() -> PriorityQueue<K, T>
fn default() -> PriorityQueue<K, T>
Returns the “default value” for a type. Read more
Source§impl<K, T> FromIterator<(K, T)> for PriorityQueue<K, T>where
K: Ord,
impl<K, T> FromIterator<(K, T)> for PriorityQueue<K, T>where
K: Ord,
Source§fn from_iter<I>(iter: I) -> PriorityQueue<K, T>where
I: IntoIterator<Item = (K, T)>,
fn from_iter<I>(iter: I) -> PriorityQueue<K, T>where
I: IntoIterator<Item = (K, T)>,
Creates a value from an iterator. Read more
Auto Trait Implementations§
impl<K, T> Freeze for PriorityQueue<K, T>
impl<K, T> RefUnwindSafe for PriorityQueue<K, T>where
K: RefUnwindSafe,
T: RefUnwindSafe,
impl<K, T> Send for PriorityQueue<K, T>
impl<K, T> Sync for PriorityQueue<K, T>
impl<K, T> Unpin for PriorityQueue<K, T>
impl<K, T> UnwindSafe for PriorityQueue<K, T>where
K: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more