= Circular buffer
= Ring buffer
{synonym}
A <circular buffer> stores a changing <sequence> in a fixed-capacity <array>, reusing slots by wrapping <array indices> through <modular arithmetic>. A front <array index> and an occupied count can represent a <FIFO queue> without shifting entries after removal. The physical <array> stays in place; the position at which its logical <sequence> begins moves. This makes a <circular buffer> useful when storage must remain bounded while successive items arrive and leave.
Capacity and overflow behavior are separate choices. A rejecting <FIFO queue> preserves all accepted items until removal and reports failure on a full insertion. An overwriting <circular buffer> deliberately discards its oldest item to retain the newest arrivals. These are different <application programming interfaces>. The existing <representation independence> example specifies the rejecting policy and gives its <abstraction function> and correctness argument against a shifting <array> implementation.
Back to article page