How to make the Ring Buffer circular?

The chapter 8: Queues talks about Ring buffer implementation. Yet this buffer is not circular. It does not wrap around and it does not start from the beginning when full. How to make it circular?


@jomoka Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi @tomn , could you please give some more context on your use case? Maybe an example test case? Ring Buffer implementation is circular in the sense that it has a fixed size, and reuses other slots in an array.

So for example if you had the following data set of size 4:

[1, 2, 8, 3]

If you appended another element (10) it would override the next write pointer in the ring buffer:

[10, 2, 8, 3]

Hope this makes sense. thanks!