A double-ended queue implemented as a circular buffer

Struct Deque

pub struct Deque<T> {
    priv nelts: uint,
    priv lo: uint,
    priv hi: uint,
    priv elts: ~[Option<T>],
}

Struct DequeIterator

pub struct DequeIterator<'self, T> {
    priv idx: uint,
    priv nelts: uint,
    priv used: uint,
    priv vec: &'self [Option<T>],
}

Deque iterator

Struct DequeMutIterator

pub struct DequeMutIterator<'self, T> {
    priv idx: uint,
    priv nelts: uint,
    priv used: uint,
    priv vec: &'self mut [Option<T>],
}

Deque mutable iterator

Struct DequeMutRevIterator

pub struct DequeMutRevIterator<'self, T> {
    priv idx: uint,
    priv nelts: uint,
    priv used: uint,
    priv vec: &'self mut [Option<T>],
}

Deque mutable reverse iterator

Struct DequeRevIterator

pub struct DequeRevIterator<'self, T> {
    priv idx: uint,
    priv nelts: uint,
    priv used: uint,
    priv vec: &'self [Option<T>],
}

Deque reverse iterator

Implementation of Container for Deque<T> where <T>

Method len

fn len(&self) -> uint

Return the number of elements in the deque

Method is_empty

fn is_empty(&self) -> bool

Return true if the deque contains no elements

Implementation of Mutable for Deque<T> where <T>

Method clear

fn clear(&mut self)

Clear the deque, removing all values.

Implementation for Deque<T> where <T>

Method new

fn new() -> Deque<T>

Create an empty Deque

Method peek_front

fn peek_front<'a>(&'a self) -> &'a T

Return a reference to the first element in the deque

Fails if the deque is empty

Method peek_back

fn peek_back<'a>(&'a self) -> &'a T

Return a reference to the last element in the deque

Fails if the deque is empty

Method get

fn get<'a>(&'a self, i: int) -> &'a T

Retrieve an element in the deque by index

Fails if there is no element with the given index

Method each

fn each(&self, f: &fn(&T) -> bool) -> bool

Iterate over the elements in the deque

Method eachi

fn eachi(&self, f: &fn(uint, &T) -> bool) -> bool

Iterate over the elements in the deque by index

Method pop_front

fn pop_front(&mut self) -> T

Remove and return the first element in the deque

Fails if the deque is empty

Method pop_back

fn pop_back(&mut self) -> T

Remove and return the last element in the deque

Fails if the deque is empty

Method add_front

fn add_front(&mut self, t: T)

Prepend an element to the deque

Method add_back

fn add_back(&mut self, t: T)

Append an element to the deque

Method reserve

fn reserve(&mut self, n: uint)

Reserve capacity for exactly n elements in the given deque, doing nothing if self's capacity is already equal to or greater than the requested capacity

Arguments

  • n - The number of elements to reserve space for

Method reserve_at_least

fn reserve_at_least(&mut self, n: uint)

Reserve capacity for at least n elements in the given deque, over-allocating in case the caller needs to reserve additional space.

Do nothing if self's capacity is already equal to or greater than the requested capacity.

Arguments

  • n - The number of elements to reserve space for

Method iter

fn iter<'a>(&'a self) -> DequeIterator<'a, T>

Front-to-back iterator.

Method mut_iter

fn mut_iter<'a>(&'a mut self) -> DequeMutIterator<'a, T>

Front-to-back iterator which returns mutable values.

Method rev_iter

fn rev_iter<'a>(&'a self) -> DequeRevIterator<'a, T>

Back-to-front iterator.

Method mut_rev_iter

fn mut_rev_iter<'a>(&'a mut self) -> DequeMutRevIterator<'a, T>

Back-to-front iterator which returns mutable values.

Implementation of Iterator<&'self T> for DequeIterator<'self, T> where <'self, T>

Method next

fn next(&mut self) -> Option<&'self T>

Implementation of Iterator<&'self T> for DequeRevIterator<'self, T> where <'self, T>

Method next

fn next(&mut self) -> Option<&'self T>

Implementation of Iterator<&'self mut T> for DequeMutIterator<'self, T> where <'self, T>

Method next

fn next(&mut self) -> Option<&'self mut T>

Implementation of Iterator<&'self mut T> for DequeMutRevIterator<'self, T> where <'self, T>

Method next

fn next(&mut self) -> Option<&'self mut T>