Group Group Group Group Group Group Group Group Group

How to make the Ring Buffer circular?

#1

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?

#2

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

#3

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]
 w            

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

[10, 2, 8, 3]
      w       

Hope this makes sense. thanks!