pub trait QueueChecker<P> {
// Required methods
fn is_empty(&self) -> bool;
fn is_full(&self) -> bool;
fn len(&self) -> P;
fn max_capacity(&self) -> P;
}Available on crate feature
queue only.Expand description
Trait to define all information getter from the queue
use prosa_utils::queue::QueueChecker;
fn queue_checker<Q>(queue: Q)
where
Q: QueueChecker<usize>,
{
if queue.is_empty() {
assert!(!queue.is_full());
assert_eq!(0, queue.len());
} else if queue.is_full() {
assert!(!queue.is_empty());
assert_eq!(queue.max_capacity(), queue.len());
}
}Required Methods§
Sourcefn is_full(&self) -> bool
fn is_full(&self) -> bool
Checks if the queue is full.
Prefer this method over len() != max_capacity()
Sourcefn max_capacity(&self) -> P
fn max_capacity(&self) -> P
Returns the maximum item capacity of the queue.