Struct cbuf::CBuf
[−]
[src]
pub struct CBuf<T> { // some fields omitted }
Circular Buffer
Turns Vec
into a Circular buffer with head and tail indexes.
Methods
impl<T: CopyOrClone> CBuf<T> where T: Clone
[src]
fn new(buf: Vec<T>) -> CBuf<T>
Create new CBuf
Length (not capacity) will be used to store elements in the circular buffer.
fn is_full(&self) -> bool
Is buffer full?
fn is_empty(&self) -> bool
Is buffer empty?
fn peek(&mut self) -> Option<T>
Peek next element from the CBuf without removing it
Returns None
if buffer is empty.
fn peek_unchecked(&mut self) -> T
Peek next element from the CBuf without removing it
Makes the buffer misbehave if it's empty.
fn get(&mut self) -> Option<T>
Remove one element from the CBuf
Returns None
if buffer is empty.
fn get_unchecked(&mut self) -> T
Remove one element from the CBuf
Makes the buffer misbehave if it's empty.
fn put(&mut self, val: T)
Add element the buffer
Ignores the write if buffer is full.
fn put_unchecked(&mut self, val: T)
Add element the buffer
Makes the buffer misbehave if it's full.