Skip to content
Search

Circular buffer

lastmod 2018-08-17created 2016-12-302 edits

A circular buffer is a data structure that lets a fixed-size buffer be used as if its two ends were connected. With a circular buffer, a plain array can be used like a deque with almost no performance loss.

Implementation

A circular buffer usually consists of four elements:

  • A fixed-size array
  • The size of the array
  • The position of the first data entered
  • The position of the last data entered

Instead of the position of the last data entered, some implementations store the number of data items entered.

See also

Favorite site