Trait BidirectedQueue

Source
pub trait BidirectedQueue<T>: Default {
    // Required methods
    fn push_front(&mut self, t: T);
    fn push_back(&mut self, t: T);
    fn pop_front(&mut self) -> Option<T>;
    fn pop_back(&mut self) -> Option<T>;
    fn clear(&mut self);
    fn len(&self) -> usize;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A queue that supports both popping and pushing at front and back.

Required Methods§

Source

fn push_front(&mut self, t: T)

Insert an element at the front of the queue.

Source

fn push_back(&mut self, t: T)

Insert an element at the back of the queue.

Source

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

Remove and return an element from the front of the queue.

Source

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

Remove and return an element from the back of the queue.

Source

fn clear(&mut self)

Remove all elements from the queue without returning them.

Source

fn len(&self) -> usize

Return the amount of elements currently in the queue.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if the queue contains no elements.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> BidirectedQueue<T> for LinkedList<T>

Source§

fn push_front(&mut self, t: T)

Source§

fn push_back(&mut self, t: T)

Source§

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

Source§

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

Source§

fn clear(&mut self)

Source§

fn len(&self) -> usize

Source§

impl<T> BidirectedQueue<T> for VecDeque<T>

Source§

fn push_front(&mut self, t: T)

Source§

fn push_back(&mut self, t: T)

Source§

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

Source§

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

Source§

fn clear(&mut self)

Source§

fn len(&self) -> usize

Implementors§