Struct j2ds::ElasticRingBuffer [−][src]
pub struct ElasticRingBuffer<T: Clone> { /* fields omitted */ }
A FIFO buffer with a fixed length that adjusts to requests that would otherwise overflow or underflow.
When an ElasticRingBuffer
doesn't have enough elements to
satisfy a request, it will "stretch" the values it does have by
repeating them to fill the request.
And when the buffer is getting too full (past its ideal max length), elements will be uniformly dropped to return the queue to its ideal length.
Methods
impl<T: Clone> ElasticRingBuffer<T>
[src]
impl<T: Clone> ElasticRingBuffer<T>
pub fn new(size: usize, value: T, ideal_max_len: usize) -> ElasticRingBuffer<T>
[src]
pub fn new(size: usize, value: T, ideal_max_len: usize) -> ElasticRingBuffer<T>
Create a new ElasticRingBuffer
with the given size. value
will be used as the default value for the
queue. ideal_max_len
is the threshold where the buffer will
begin dropping elements during requests
pub fn pop_front_slice(&mut self, values: &mut [T]) -> ElasticPopResult
[src]
pub fn pop_front_slice(&mut self, values: &mut [T]) -> ElasticPopResult
Fill values
with elements. See ElasticPopResult
for the
possible outcomes of this request.
pub fn push_back_slice(&mut self, values: &[T]) -> bool
[src]
pub fn push_back_slice(&mut self, values: &[T]) -> bool
Add all values
to the buffer. If there is not enough room in
the queue then no values are added and the return value is
false
pub fn push_back(&mut self, value: T) -> bool
[src]
pub fn push_back(&mut self, value: T) -> bool
Add value
to the end of the queue. Returns false if there is
not enough room in the queue
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns the number of values in the buffer
pub fn capacity(&self) -> usize
[src]
pub fn capacity(&self) -> usize
Returns the number of free slots in the buffer
pub fn max_len(&self) -> usize
[src]
pub fn max_len(&self) -> usize
Returns the max number of values that can ever be stored in the buffer
Auto Trait Implementations
impl<T> Send for ElasticRingBuffer<T> where
T: Send,
impl<T> Send for ElasticRingBuffer<T> where
T: Send,
impl<T> Sync for ElasticRingBuffer<T> where
T: Sync,
impl<T> Sync for ElasticRingBuffer<T> where
T: Sync,