Struct using_queue::UsingQueue
source · [−]pub struct UsingQueue<T> { /* private fields */ }
Expand description
Special queue-like datastructure that includes the notion of usage to avoid items that were queued but never used from making it into the queue.
Implementations
sourceimpl<T> UsingQueue<T>
impl<T> UsingQueue<T>
sourcepub fn new(max_size: usize) -> UsingQueue<T>
pub fn new(max_size: usize) -> UsingQueue<T>
Create a new struct with a maximum size of max_size
.
sourcepub fn peek_last_ref(&self) -> Option<&T>
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.
sourcepub fn use_last_ref(&mut self) -> Option<&T>
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()
.
sourcepub fn set_pending(&mut self, b: T)
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.
sourcepub fn get_used_if<P>(&mut self, action: GetAction, predicate: P) -> Option<T> where
P: Fn(&T) -> bool,
T: Clone,
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
.
sourcepub fn get_pending_if<P>(&mut self, predicate: P) -> Option<T> where
P: Fn(&T) -> bool,
T: Clone,
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> 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more