Struct collections::ringbuf::RingBuf
pub struct RingBuf<T> { // some fields omitted }
RingBuf is a circular buffer that implements Deque.
Methods
impl<T> RingBuf<T>
fn new() -> RingBuf<T>
Create an empty RingBuf
fn with_capacity(n: uint) -> RingBuf<T>
Create an empty RingBuf with space for at least n
elements.
fn get<'a>(&'a self, i: uint) -> &'a T
Retrieve an element in the RingBuf by index
Fails if there is no element with the given index
fn get_mut<'a>(&'a mut self, i: uint) -> &'a mut T
Retrieve an element in the RingBuf by index
Fails if there is no element with the given index
fn swap(&mut self, i: uint, j: uint)
Swap elements at indices i
and j
i
and j
may be equal.
Fails if there is no element with the given index
fn reserve_exact(&mut self, n: uint)
Reserve capacity for exactly n
elements in the given RingBuf,
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
fn reserve(&mut self, n: uint)
Reserve capacity for at least n
elements in the given RingBuf,
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
fn iter<'a>(&'a self) -> Items<'a, T>
Front-to-back iterator.
fn rev_iter<'a>(&'a self) -> Rev<Items<'a, T>>
Back-to-front iterator.
fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T>
Front-to-back iterator which returns mutable values.
fn mut_rev_iter<'a>(&'a mut self) -> Rev<MutItems<'a, T>>
Back-to-front iterator which returns mutable values.
Trait Implementations
impl<T> Container for RingBuf<T>
fn len(&self) -> uint
Return the number of elements in the RingBuf
impl<T> Mutable for RingBuf<T>
fn clear(&mut self)
Clear the RingBuf, removing all values.
impl<T> Deque<T> for RingBuf<T>
fn front<'a>(&'a self) -> Option<&'a T>
Return a reference to the first element in the RingBuf
fn front_mut<'a>(&'a mut self) -> Option<&'a mut T>
Return a mutable reference to the first element in the RingBuf
fn back<'a>(&'a self) -> Option<&'a T>
Return a reference to the last element in the RingBuf
fn back_mut<'a>(&'a mut self) -> Option<&'a mut T>
Return a mutable reference to the last element in the RingBuf
fn pop_front(&mut self) -> Option<T>
Remove and return the first element in the RingBuf, or None if it is empty
fn pop_back(&mut self) -> Option<T>
Remove and return the last element in the RingBuf, or None if it is empty
fn push_front(&mut self, t: T)
Prepend an element to the RingBuf
fn push_back(&mut self, t: T)
Append an element to the RingBuf