rokdocs
v0.1

rok::core::collections::deque

rok::core::collections::deque - 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

Deque

pub struct Deque<T>
  • pub const fn new() -> Deque<T>
  • pub const fn with_capacity(cap: usize) -> Deque<T>
  • pub const fn len(self) -> usize
  • pub fn is_empty(self) -> bool
  • pub fn capacity(self) -> usize
  • pub const fn push_back(self, x: T)
  • pub const fn push_front(self, x: T)
  • pub const fn pop_front(self) -> T | none
  • pub const fn pop_back(self) -> T | none
  • pub const fn get(self, i: usize) -> T | none

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

  • pub const fn set(self, i: usize, x: T) throws (IndexError)

    Overwrite element i from the front; throws out of bounds.

  • pub fn front(self) -> T | none
  • pub fn back(self) -> T | none
  • pub fn clear(self)
  • pub const fn iter(self) -> DequeIter<T>
Trait implementations 7
  • impl<T> !Sync for Deque<T>
  • impl<T> IntoIterator for Deque<T>
  • impl<T> Default for Deque<T>
  • impl<T> Index<usize> for Deque<T>
  • impl<T> IndexSet<usize> for Deque<T>
  • impl<T: Debug> Debug for Deque<T>
  • impl<T> Transfer for Deque<T>

DequeIter

pub struct DequeIter<T>

Front to back.

Trait implementations 1
  • impl<T> Iterator for DequeIter<T>