Ring Buffer

Why Trust Techopedia

What Does Ring Buffer Mean?

A ring buffer is a data structure that is treated as circular although it its implementation is linear. A circular buffer is typically used as a data queue. A circular buffer is a popular way to implement a data stream because the code can be compact.

Advertisements

A ring buffer is also known as a circular buffer, circular queue or cyclic buffer.

Techopedia Explains Ring Buffer

A ring buffer is a common implementation of a queue. It is popular because circular queues are easy to implement. While a ring buffer is represented as a circle, in the underlying code, a ring buffer is linear. A ring buffer exists as a fixed-length array with two pointers: one that represents the head of a queue, and another that represents the tail. In a queue, elements are added to the tail of the queue in a “FIFO” (first in-first out) fashion. The first elements of the queue are removed from the head in the order they were added. When the head pointer gets to the end of the array, it wraps around to the first element in the array. Any data in the buffer is overwritten. The head of the queue is different from the first element in the actual array and both pointers move as elements are added and removed.

One disadvantage of a ring buffer is its fixed size. For queues where elements need to be added and removed in the middle, not just at the start and end of a buffer, an implementation as a linked list is the preferred approach.

Advertisements

Related Terms

Margaret Rouse
Technology Specialist
Margaret Rouse
Technology Specialist

Margaret is an award-winning writer and educator known for her ability to explain complex technical topics to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles in the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret’s idea of ​​a fun day is to help IT and business professionals to learn to speak each other’s highly specialized languages.