pub struct TinySetQueue<'a, T, S>where
S: SetBacking + ?Sized,{ /* private fields */ }Expand description
A fixed-capacity, allocation-free queue with direct-mapped membership tracking.
Values are converted to indices via Into<usize>, so the queue works best when
keys are dense integers in the range 0..N. Sparse identifiers (e.g. {5, 1_000_000})
require a membership backing large enough to cover the full domain.
§Sizing
This queue never allocates and never resizes at runtime. If an index
exceeds the membership capacity, push returns an error.
Implementations§
Source§impl<'a, T, S> TinySetQueue<'a, T, S>
impl<'a, T, S> TinySetQueue<'a, T, S>
Sourcepub fn new(
buf: &'a mut [T],
in_queue: &'a mut S,
mode: MembershipMode,
order: ProcessingOrder,
) -> Self
pub fn new( buf: &'a mut [T], in_queue: &'a mut S, mode: MembershipMode, order: ProcessingOrder, ) -> Self
Constructs a queue backed by caller-provided storage.
bufsupplies the ring-buffer storage used for pending values.in_queueis the direct-mapped membership backing (e.g.[bool],[u64]).modedetermines whether membership clears onpop.orderselects FIFO or LIFO processing of queued values.
in_queue.capacity() must exceed any index produced by value.into(). When the
clear_on_new feature (enabled by default) is active, the backing is cleared to
prevent stale membership flags.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the queue without freeing any backing storage.
All membership flags are reset and the queue becomes empty.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the maximum number of pending items the queue can hold.
Sourcepub fn push(&mut self, value: T) -> Result<PushResult, T>
pub fn push(&mut self, value: T) -> Result<PushResult, T>
Pushes a value into the queue unless it is already present.
§Errors
Returns Err(value) if the queue is full or if value.into() exceeds the
bounds of the membership backing.
Sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Pops the next value according to the configured processing order, if any.
Membership is cleared in MembershipMode::InQueue and retained in
MembershipMode::Visited.