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]

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

Fill values with elements. See ElasticPopResult for the possible outcomes of this request.

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

Add value to the end of the queue. Returns false if there is not enough room in the queue

Returns the number of values in the buffer

Returns the number of free slots in the buffer

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> Sync for ElasticRingBuffer<T> where
    T: Sync