PriorityQueue

Struct PriorityQueue 

Source
pub struct PriorityQueue<const N: usize, T: Copy> { /* private fields */ }
Expand description

A simple prioritized queue

Implementations§

Source§

impl<const N: usize, T> PriorityQueue<N, T>
where T: Copy + Send,

Source

pub const fn new() -> Self

Create a new PriorityQueue

Source

pub fn push(&self, prio: u32, item: T) -> Result<(), T>

Write an item to the queue

§Arguments
  • prio: The priority of the item. Lower priority values will be read first. Bit 31 is reserved and must always be zero, so the maximum priority value is (2**31-1)
  • item: The item to queue
Source

pub fn pop(&self) -> Option<T>

Remove the queue item with the lowest priority value

Returns: The item with the lowest priority value in the queue, or None if the queue is empty

Trait Implementations§

Source§

impl<const N: usize, T: Debug + Copy> Debug for PriorityQueue<N, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const N: usize, T: Copy + Send> Default for PriorityQueue<N, T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const N: usize, T> !Freeze for PriorityQueue<N, T>

§

impl<const N: usize, T> !RefUnwindSafe for PriorityQueue<N, T>

§

impl<const N: usize, T> Send for PriorityQueue<N, T>
where T: Send,

§

impl<const N: usize, T> Sync for PriorityQueue<N, T>
where T: Send,

§

impl<const N: usize, T> Unpin for PriorityQueue<N, T>
where T: Unpin,

§

impl<const N: usize, T> UnwindSafe for PriorityQueue<N, T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> FormatOrDebug for T
where T: Debug,