Trait Queue

Source
pub trait Queue: Collection + Iter {
    // Required methods
    fn push(&mut self, item: Self::Item)
       where Self: AddRemove;
    fn front(&self) -> Option<&Self::Item>;
    fn pop_front(&mut self) -> Option<Self::Item>
       where Self: AddRemove;
}
Expand description

A queue.

Required Methods§

Source

fn push(&mut self, item: Self::Item)
where Self: AddRemove,

Pushes the given item onto the queue.

For FIFO queues, this pushes the item onto the back of the queue. For other queues, the location of the newly inserted item is unspecified.

Source

fn front(&self) -> Option<&Self::Item>

Returns a reference to the item at the front of the queue.

Returns None if the queue is empty.

Source

fn pop_front(&mut self) -> Option<Self::Item>
where Self: AddRemove,

Removes the item at the front of the queue and returns it.

Returns None if the queue was empty.

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> Queue for LinkedList<T>

Source§

fn push(&mut self, item: T)

Source§

fn front(&self) -> Option<&T>

Source§

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

Source§

impl<T> Queue for VecDeque<T>

Source§

fn push(&mut self, item: T)

Source§

fn front(&self) -> Option<&T>

Source§

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

Source§

impl<T: Ord> Queue for BinaryHeap<T>

Source§

fn push(&mut self, item: T)

Source§

fn front(&self) -> Option<&T>

Source§

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

Implementors§