Skip to main content

BoxQueue

Struct BoxQueue 

Source
pub struct BoxQueue<N: BoxQueueNode> { /* private fields */ }
Expand description

A queue where nodes are independently allocated via Box.

This is usually much slower than arena queue, but is more memory efficient as the memory used for each node is deallocated once the node is removed.

Usage is only recommended when memory efficiency is needed. If possible, DualLinkBoxQueue should be preferred over SingleLinkBoxQueue, as it almost always faster.

(difference being that DualLinkBoxQueueNode has an extra usize worth of bytes per node)

Trait Implementations§

Source§

impl<N: BoxQueueNode> ConstDefault for BoxQueue<N>

Available on crate feature const-default only.
Source§

const DEFAULT: Self

The constant default value.
Source§

impl<N: BoxQueueNode> Default for BoxQueue<N>

Source§

fn default() -> Self

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

impl<N: BoxQueueNode> PriorityQueue<<N as BoxQueueNode>::Data> for BoxQueue<N>

Source§

type Handle = BoxQueueHandle<N>

Source§

type SharedHandle = SharedBoxQueueHandle<N>

Source§

fn enqueue(&mut self, data: N::Data) -> Self::Handle

Enqueue an entry with provided data. This must return a unique handle for this node.
Source§

fn get_by_handle(&self, handle: &Self::Handle) -> &N::Data

Get an entry’s data by its handle
Source§

fn iter_at<'a>( &'a self, after: Option<&Self::Handle>, ) -> impl Iterator<Item = &'a N::Data>
where N::Data: 'a,

Iterate through the queue starting at a provided handle (or None to start with the head node) (including the provided value)
Source§

fn dequeue( &mut self, BoxQueueHandle: Self::Handle, ) -> (Option<&N::Data>, Option<Self::SharedHandle>)

Dequeue an entry by its handle
Source§

fn is_empty(&self) -> bool

Returns true if the queue is empty
Source§

fn update_node( &mut self, handle: &Self::Handle, update: impl FnOnce(&mut N::Data) -> bool, )

Update a node via handle ref. update is a fn that should return true if the node’s priority changed. i.e. if update returns false, the queue does not need to consider repositioning the changed node.
Source§

fn head_handle(&self) -> Option<Self::SharedHandle>

Get a SharedHandle for the first node in the queue
Source§

fn get_next_handle(&self, handle: &Self::Handle) -> Option<Self::SharedHandle>

Get the handle for the next node after an input handle (or None if the provided handle is the tail node)
Source§

fn iter<'a>(&'a self) -> impl Iterator<Item = &'a P>
where P: 'a,

Iterate through the queue from the start.
Source§

fn head(&self) -> Option<&P>

Get the first node in the queue

Auto Trait Implementations§

§

impl<N> Freeze for BoxQueue<N>

§

impl<N> RefUnwindSafe for BoxQueue<N>
where N: RefUnwindSafe,

§

impl<N> Send for BoxQueue<N>
where N: Send,

§

impl<N> Sync for BoxQueue<N>
where N: Sync,

§

impl<N> Unpin for BoxQueue<N>

§

impl<N> UnsafeUnpin for BoxQueue<N>

§

impl<N> UnwindSafe for BoxQueue<N>
where N: 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<P, Q> MutexQueue<P> for Q

Source§

impl<T, P> SemaphoreQueue<P> for T