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>
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>
pub fn get_used_if<P>(&mut self, action: GetAction, predicate: P) -> Option<T>
Fork-function for take_used_if
and clone_used_if
.
Sourcepub fn get_pending_if<P>(&mut self, predicate: P) -> Option<T>
pub fn get_pending_if<P>(&mut self, predicate: P) -> Option<T>
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.