[][src]Struct rust_algorithm_club::collections::Deque

pub struct Deque<T> { /* fields omitted */ }

A double-ended queue (abbreviated to deque), for which elements can be added or remove from both back and front ends.

Underneath the hood, this Deque uses a contiguous memory block as a ring buffer to store values.

References:

Implementations

impl<T> Deque<T>[src]

pub fn new() -> Self[src]

Constructs a new, empty Deque<T>.

For convenience, the deque initially allocates a region of a single T.

pub fn push_front(&mut self, elem: T)[src]

Prepends the given element value to the beginning of the container.

Parameters

  • elem - The element to prepend.

Complexity

Constant.

pub fn push_back(&mut self, elem: T)[src]

Appends the given element value to the end of the container.

Parameters

  • elem - The element to append.

Complexity

Constant.

pub fn pop_front(&mut self) -> Option<T>[src]

Removes and returns the first element of the container. If there are no elements in the container, return None.

Complexity

Constant.

pub fn pop_back(&mut self) -> Option<T>[src]

Removes and returns the last element of the container. If there are no elements in the container, return None.

Complexity

Constant.

pub fn front(&self) -> Option<&T>[src]

Peeks the first element of the container. If there are no elements in the container, return None.

Complexity

Constant.

pub fn back(&self) -> Option<&T>[src]

Peeks the last element of the container. If there are no elements in the container, return None.

Complexity

Constant.

pub fn is_empty(&self) -> bool[src]

Checks whether the container is empty.

Complexity

Constant.

pub fn len(&self) -> usize[src]

Gets the number of elements in the container.

Complexity

Constant.

pub fn iter(&self) -> Iter<'_, T>[src]

Creates an iterator that yields immutable reference of each element.

pub fn iter_mut(&mut self) -> IterMut<'_, T>[src]

Creates an iterator that yields mutable reference of each element.

Trait Implementations

impl<T: Debug> Debug for Deque<T>[src]

impl<T> Drop for Deque<T>[src]

impl<T> Index<usize> for Deque<T>[src]

type Output = T

The returned type after indexing.

impl<T> IndexMut<usize> for Deque<T>[src]

impl<T> IntoIterator for Deque<T>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?

impl<'a, T> IntoIterator for &'a Deque<T>[src]

type Item = &'a T

The type of the elements being iterated over.

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?

impl<'a, T> IntoIterator for &'a mut Deque<T>[src]

type Item = &'a mut T

The type of the elements being iterated over.

type IntoIter = IterMut<'a, T>

Which kind of iterator are we turning this into?

Auto Trait Implementations

impl<T> RefUnwindSafe for Deque<T> where
    T: RefUnwindSafe
[src]

impl<T> !Send for Deque<T>[src]

impl<T> !Sync for Deque<T>[src]

impl<T> Unpin for Deque<T>[src]

impl<T> UnwindSafe for Deque<T> where
    T: RefUnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.