pub struct PriorityQueue<T> { /* private fields */ }Expand description
§Priority Queue
§Description
A priority queue is a data structure that stores elements in a specific order.
A Rust port of the tinyqueue code.
§Usage
use gistools::data_structures::PriorityQueue;
let mut queue = PriorityQueue::new(|a: &i32, b: &i32| a.cmp(b));
queue.push(3);
queue.push(1);
queue.push(2);
assert_eq!(queue.peek(), Some(&1));
assert_eq!(queue.pop(), Some(1));
assert_eq!(queue.len(), 2);§Links
Implementations§
Source§impl<T> PriorityQueue<T>where
T: Clone,
impl<T> PriorityQueue<T>where
T: Clone,
Sourcepub fn new(compare: PriorityCompare<T>) -> Self
pub fn new(compare: PriorityCompare<T>) -> Self
Creates a new priority queue with an optional comparison function.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for PriorityQueue<T>
impl<T> RefUnwindSafe for PriorityQueue<T>where
T: RefUnwindSafe,
impl<T> Send for PriorityQueue<T>where
T: Send,
impl<T> Sync for PriorityQueue<T>where
T: Sync,
impl<T> Unpin for PriorityQueue<T>where
T: Unpin,
impl<T> UnwindSafe for PriorityQueue<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more