docs

You are reading the docs for v0.1.0. Nabi 0.1.0 is no longer supported. Latest release: v0.1.3 →

core::collections::deque

On this page

Deque<T>, a growable ring buffer with O(1) push and pop at both ends. meta holds [head, len, cap]; a vacated slot is overwritten with a zeroed T so the deque does not keep a popped value alive.

Structs

DequeSource

pub struct Deque<T>

A growable ring buffer with O(1) push and pop at both ends.

  • pub const fn new() -> Deque<T>§

    Source

    An empty deque.

  • pub const fn with_capacity(cap: usize) -> Deque<T>§

    Source

    Room for cap items before the first growth.

  • pub const fn len(self) -> usize§

    Source

    The number of items.

  • pub const fn is_empty(self) -> bool§

    Source

    true when the deque holds no item.

  • pub const fn capacity(self) -> usize§

    Source

    The items the ring holds before it grows.

  • pub const fn push_back(self, x: T)§

    Source

    Add x at the back.

  • pub const fn push_front(self, x: T)§

    Source

    Add x at the front.

  • pub const fn pop_front(self) -> T | none§

    Source

    Remove and return the front item.

  • pub const fn pop_back(self) -> T | none§

    Source

    Remove and return the back item.

  • pub const fn get(self, i: usize) -> T | none§

    Source

    Element i from the front, or none out of bounds.

  • pub const fn front(self) -> T | none§

    Source

    The front item.

  • pub const fn back(self) -> T | none§

    Source

    The back item.

  • pub const fn clear(self)§

    Source

    Drop every item.

  • pub const fn iter(self) -> DequeIter<T>§

    Source

    The items, front to back, lazily.

Trait implementations 12

DequeIterSource

pub struct DequeIter<T>

Front to back.

Trait implementations 2