Struct UsingQueue

Source
pub struct UsingQueue<T> { /* private fields */ }
Expand description

Special queue-like data structure that includes the notion of usage to avoid items that were queued but never used from making it into the queue.

Implementations§

Source§

impl<T> UsingQueue<T>

Source

pub fn new(max_size: usize) -> UsingQueue<T>

Create a new struct with a maximum size of max_size.

Source

pub fn peek_last_ref(&self) -> Option<&T>

Return a reference to the item at the top of the queue (or None if the queue is empty); it doesn’t constitute noting that the item is used.

Source

pub fn use_last_ref(&mut self) -> Option<&T>

Return a reference to the item at the top of the queue (or None if the queue is empty); this constitutes using the item and will remain in the queue for at least another max_size invocations of set_pending() + use_last_ref().

Source

pub fn set_pending(&mut self, b: T)

Place an item on the end of the queue. The previously pending item will be removed if use_last_ref() since it was set.

Source

pub fn is_in_use(&self) -> bool

Is there anything in the queue currently?

Source

pub fn reset(&mut self)

Clears everything; the queue is entirely reset.

Source

pub fn get_used_if<P>(&mut self, action: GetAction, predicate: P) -> Option<T>
where P: Fn(&T) -> bool, T: Clone,

Fork-function for take_used_if and clone_used_if.

Source

pub fn get_pending_if<P>(&mut self, predicate: P) -> Option<T>
where P: Fn(&T) -> bool, T: Clone,

Returns a clone of the pending block if f returns true with a reference to it as a parameter, otherwise None.

If pending block is not available will clone the first of the used blocks that match the predicate.

Auto Trait Implementations§

§

impl<T> Freeze for UsingQueue<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for UsingQueue<T>
where T: RefUnwindSafe,

§

impl<T> Send for UsingQueue<T>
where T: Send,

§

impl<T> Sync for UsingQueue<T>
where T: Sync,

§

impl<T> Unpin for UsingQueue<T>
where T: Unpin,

§

impl<T> UnwindSafe for UsingQueue<T>
where T: UnwindSafe,

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.