Trait ringbuffer::RingBufferExt[][src]

pub trait RingBufferExt<T>: RingBuffer<T> + RingBufferRead<T> + RingBufferWrite<T> + Index<isize, Output = T> + IndexMut<isize> + FromIterator<T> {
Show methods fn clear(&mut self);
fn get(&self, index: isize) -> Option<&T>;
fn get_mut(&mut self, index: isize) -> Option<&mut T>;
fn get_absolute(&self, index: usize) -> Option<&T>;
fn get_absolute_mut(&mut self, index: usize) -> Option<&mut T>; fn peek(&self) -> Option<&T> { ... }
fn front(&self) -> Option<&T> { ... }
fn front_mut(&mut self) -> Option<&mut T> { ... }
fn back(&self) -> Option<&T> { ... }
fn back_mut(&mut self) -> Option<&mut T> { ... }
fn iter_mut(&mut self) -> RingBufferMutIterator<'_, T, Self> { ... }
fn iter(&self) -> RingBufferIterator<'_, T, Self> { ... }
fn to_vec(&self) -> Vec<T>
    where
        T: Clone
, { ... }
fn contains(&self, elem: &T) -> bool
    where
        T: PartialEq
, { ... }
}

Defines behaviour for ringbuffers which allow them to be used as a general purpose buffer. With this trait, arbitrary access of elements in the buffer is possible.

Required methods

fn clear(&mut self)[src]

Empties the buffer entirely. Sets the length to 0 but keeps the capacity allocated.

fn get(&self, index: isize) -> Option<&T>[src]

Gets a value relative to the current index. 0 is the next index to be written to with push. -1 and down are the last elements pushed and 0 and up are the items that were pushed the longest ago.

fn get_mut(&mut self, index: isize) -> Option<&mut T>[src]

Gets a value relative to the current index mutably. 0 is the next index to be written to with push. -1 and down are the last elements pushed and 0 and up are the items that were pushed the longest ago.

fn get_absolute(&self, index: usize) -> Option<&T>[src]

Gets a value relative to the start of the array (rarely useful, usually you want Self::get)

fn get_absolute_mut(&mut self, index: usize) -> Option<&mut T>[src]

Gets a value mutably relative to the start of the array (rarely useful, usually you want Self::get_mut)

Loading content...

Provided methods

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

Returns the value at the current index. This is the value that will be overwritten by the next push and also the value pushed the longest ago. (alias of Self::front)

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

Returns the value at the front of the queue. This is the value that will be overwritten by the next push and also the value pushed the longest ago. (alias of peek)

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

Returns a mutable reference to the value at the back of the queue. This is the value that will be overwritten by the next push. (alias of peek)

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

Returns the value at the back of the queue. This is the item that was pushed most recently.

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

Returns a mutable reference to the value at the back of the queue. This is the item that was pushed most recently.

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

Creates a mutable iterator over the buffer starting from the item pushed the longest ago, and ending at the element most recently pushed.

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

Creates an iterator over the buffer starting from the item pushed the longest ago, and ending at the element most recently pushed.

fn to_vec(&self) -> Vec<T> where
    T: Clone
[src]

Converts the buffer to a vector. This Copies all elements in the ringbuffer.

fn contains(&self, elem: &T) -> bool where
    T: PartialEq
[src]

Returns true if elem is in the ringbuffer.

Loading content...

Implementors

impl<T> RingBufferExt<T> for AllocRingBuffer<T>[src]

impl<T, const CAP: usize> RingBufferExt<T> for ConstGenericRingBuffer<T, CAP>[src]

Loading content...