Overview
A Circular Buffer reuses array slots as items are consumed, making it useful for streams and producer-consumer queues.
Stores a fixed-size queue by wrapping read and write positions around an array.
Compact metadata for implementation and discovery.
A Circular Buffer reuses array slots as items are consumed, making it useful for streams and producer-consumer queues.
Quick facts
Runtime and memory behavior at a glance.
Best
O(1)
Average
O(1)
Worst
O(1)
Space
O(capacity)
next_index = (index + 1) mod capacityMoves a pointer forward while wrapping back to the start.
Show head and tail pointers wrapping around a fixed array.
Full and empty states need a clear convention, such as storing count separately.
What each reference supports for this entry.
Data-structures reference for fixed-capacity ring buffers, head/tail indexing, queue semantics, and wraparound behavior.
Official documentation for circular-buffer fixed-capacity storage, overwrite behavior, and wraparound container operations.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Round-robin schedulers can use circular queues to rotate runnable tasks.