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.
impl<N: BoxQueueNode> ConstDefault for BoxQueue<N>
Available on crate feature
const-default only.Source§impl<N: BoxQueueNode> PriorityQueue<<N as BoxQueueNode>::Data> for BoxQueue<N>
impl<N: BoxQueueNode> PriorityQueue<<N as BoxQueueNode>::Data> for BoxQueue<N>
type Handle = BoxQueueHandle<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 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 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 dequeue(
&mut self,
BoxQueueHandle: Self::Handle,
) -> (Option<&N::Data>, Option<Self::SharedHandle>)
fn dequeue( &mut self, BoxQueueHandle: Self::Handle, ) -> (Option<&N::Data>, Option<Self::SharedHandle>)
Dequeue an entry by its handle
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 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 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)
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> 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