Summary
A
circular_array treats a fixed-size array as a loop. Indices use
modulo_indexing to
wrap_around at the ends. Track
head,
tail, and
capacity. Moving to the next slot is
constant_time. Common uses include
ring_buffer,
circular_queue, and
round_robin scheduling. Key idea: compute index as (i + step) % n. Normalize negatives with
index_normalization like (i + n) % n. Remember full vs empty rules in buffers. A circular array saves shifts and simplifies rotating data.