ringbufer
A ring buffer, also known as a circular buffer, is a data structure that uses a single, fixed-size buffer as if it were connected end-to-end. This structure lends itself easily to buffering data streams. The buffer is implemented as an array or other fixed-size data structure. When the buffer is full, the oldest data is overwritten by the newest data.
Two pointers, typically called the head and the tail, are used to manage the ring buffer. The
Ring buffers are commonly used in scenarios where data is continuously produced and consumed, such as in
The main advantage of a ring buffer is its ability to efficiently manage a stream of data