Trait kernel::collections::queue::Queue

source ·
pub trait Queue<T> {
    // Required methods
    fn has_elements(&self) -> bool;
    fn is_full(&self) -> bool;
    fn len(&self) -> usize;
    fn enqueue(&mut self, val: T) -> bool;
    fn push(&mut self, val: T) -> Option<T>;
    fn dequeue(&mut self) -> Option<T>;
    fn remove_first_matching<F>(&mut self, f: F) -> Option<T>
       where F: Fn(&T) -> bool;
    fn empty(&mut self);
    fn retain<F>(&mut self, f: F)
       where F: FnMut(&T) -> bool;
}

Required Methods§

source

fn has_elements(&self) -> bool

Returns true if there are any items in the queue, false otherwise.

source

fn is_full(&self) -> bool

Returns true if the queue is full, false otherwise.

source

fn len(&self) -> usize

Returns how many elements are in the queue.

source

fn enqueue(&mut self, val: T) -> bool

If the queue isn’t full, add a new element to the back of the queue. Returns whether the element was added.

source

fn push(&mut self, val: T) -> Option<T>

Add a new element to the back of the queue, poping one from the front if necessary.

source

fn dequeue(&mut self) -> Option<T>

Remove the element from the front of the queue.

source

fn remove_first_matching<F>(&mut self, f: F) -> Option<T>
where F: Fn(&T) -> bool,

Remove and return one (the first) element that matches the predicate.

source

fn empty(&mut self)

Remove all elements from the ring buffer.

source

fn retain<F>(&mut self, f: F)
where F: FnMut(&T) -> bool,

Retains only the elements that satisfy the predicate.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T: Copy> Queue<T> for RingBuffer<'_, T>