Expand description

A circular buffer uses a single, fixed-size buffer as if it were connected end-to-end.

This structure is also known as circular queue, cyclic buffer or ring buffer. It lends itself easily to buffering data streams.

It differs from the standard VecDeque collection by having a constant buffer size and by removing last items when the buffer gets full. It is also faster thanks to not allocating any memory while being used.

More: https://en.wikipedia.org/wiki/Circular_buffer

Complexity

MetricComplexity
Pushing data to the begging or end of the bufferO(1)
Poping data from the beginning or end of the bufferO(1)
Accessing the n-th elementO(1)

Inspiration

This implementation was inspired by C++ boos library circular_buffer

Structs

Circular buffer implementation.
A drainign iterator over CircularBuffer<T>.
An iterator that moves out of a CircularBuffer<T>.

Type Definitions

An iterator over CircularBuffer<T>.
A mutable iterator over CircularBuffer<T>.