Skip to main content

ArenaQueue

Struct ArenaQueue 

Source
pub struct ArenaQueue<N: ArenaQueueNode> { /* private fields */ }
Expand description

An arena queue - instead of having each node as a separate allocation, a block of memory is allocated for all of the nodes.

The block will never shrink, but will grow to accommodate more slots as needed.

Currently, the amount of slots allocated is always a power of two and is doubled when capacity is exceeded.

If this is an issue, BoxQueue can be used with the box-queue feature flag enabled.

It’s likely easier to use this via the type aliases SingleLinkArenaQueue and DualLinkArenaQueue.

Trait Implementations§

Source§

impl<N: ArenaQueueNode> ConstDefault for ArenaQueue<N>

Available on crate feature const-default only.
Source§

const DEFAULT: Self

The constant default value.
Source§

impl<D: ArenaQueueNode> Debug for ArenaQueue<D>

Source§

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

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

impl<N: ArenaQueueNode> Default for ArenaQueue<N>

Source§

fn default() -> Self

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

impl<N: ArenaQueueNode> Drop for ArenaQueue<N>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<N: ArenaQueueNode> PriorityQueue<<N as ArenaQueueNode>::Data> for ArenaQueue<N>

Source§

type Handle = ArenaQueueHandle<N>

Source§

type SharedHandle = SharedArenaQueueHandle<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 dequeue( &mut self, handle: Self::Handle, ) -> (Option<&N::Data>, Option<Self::SharedHandle>)

Dequeue an entry by its handle
Source§

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

Get an entry’s data by its handle
Source§

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

Get a SharedHandle for the first node in the queue
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 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 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 is_empty(&self) -> bool

Returns true if the queue is empty
Source§

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

Get the first node in the queue
Source§

impl<D: Send + ArenaQueueNode> Send for ArenaQueue<D>

Source§

impl<D: Sync + ArenaQueueNode> Sync for ArenaQueue<D>

Auto Trait Implementations§

§

impl<N> Freeze for ArenaQueue<N>

§

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

§

impl<N> Unpin for ArenaQueue<N>

§

impl<N> UnsafeUnpin for ArenaQueue<N>

§

impl<N> UnwindSafe for ArenaQueue<N>
where N: RefUnwindSafe,

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