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.
impl<N: ArenaQueueNode> ConstDefault for ArenaQueue<N>
Available on crate feature
const-default only.Source§impl<D: ArenaQueueNode> Debug for ArenaQueue<D>
impl<D: ArenaQueueNode> Debug for ArenaQueue<D>
Source§impl<N: ArenaQueueNode> Default for ArenaQueue<N>
impl<N: ArenaQueueNode> Default for ArenaQueue<N>
Source§impl<N: ArenaQueueNode> Drop for ArenaQueue<N>
impl<N: ArenaQueueNode> Drop for ArenaQueue<N>
Source§impl<N: ArenaQueueNode> PriorityQueue<<N as ArenaQueueNode>::Data> for ArenaQueue<N>
impl<N: ArenaQueueNode> PriorityQueue<<N as ArenaQueueNode>::Data> for ArenaQueue<N>
type Handle = ArenaQueueHandle<N>
Source§fn enqueue(&mut self, data: N::Data) -> Self::Handle
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>)
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
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>
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,
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,
)
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>
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)
impl<D: Send + ArenaQueueNode> Send for ArenaQueue<D>
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> 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