TinySetQueue

Struct TinySetQueue 

Source
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>
where T: Copy + Into<usize>, S: SetBacking + ?Sized,

Source

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.

  • buf supplies the ring-buffer storage used for pending values.
  • in_queue is the direct-mapped membership backing (e.g. [bool], [u64]).
  • mode determines whether membership clears on pop.
  • order selects 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.

Source

pub fn clear(&mut self)

Clears the queue without freeing any backing storage.

All membership flags are reset and the queue becomes empty.

Source

pub fn capacity(&self) -> usize

Returns the maximum number of pending items the queue can hold.

Source

pub fn len(&self) -> usize

Returns the number of items currently enqueued.

Source

pub fn is_empty(&self) -> bool

Returns true when the queue is empty.

Source

pub fn is_full(&self) -> bool

Returns true when the queue is at full capacity.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'a, T, S> Freeze for TinySetQueue<'a, T, S>
where S: ?Sized,

§

impl<'a, T, S> RefUnwindSafe for TinySetQueue<'a, T, S>

§

impl<'a, T, S> Send for TinySetQueue<'a, T, S>
where S: Send + ?Sized, T: Send,

§

impl<'a, T, S> Sync for TinySetQueue<'a, T, S>
where S: Sync + ?Sized, T: Sync,

§

impl<'a, T, S> Unpin for TinySetQueue<'a, T, S>
where S: ?Sized,

§

impl<'a, T, S> !UnwindSafe for TinySetQueue<'a, T, S>

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.