No that’s a subtly different thing. The storage is a contiguous vector, but because it is a ring buffer there must be one pair of adjacent elements that are not contiguous in memory. That’s what that comment is saying.
But because it is only one discontinuity it doesn’t affect algorithmic complexity, so it is still O(1) to access elements, unlike a linked list which is O(N).
If you google “circular buffer” there will be loads of diagrams that make it really obvious how it works.
Standard ring buffers or circular buffers are implemented as continuous vectors, with a read and write pointer.
Rust’s
VecDeque
is a ring buffer: https://doc.rust-lang.org/std/collections/struct.VecDeque.htmlNo that’s a subtly different thing. The storage is a contiguous vector, but because it is a ring buffer there must be one pair of adjacent elements that are not contiguous in memory. That’s what that comment is saying.
But because it is only one discontinuity it doesn’t affect algorithmic complexity, so it is still O(1) to access elements, unlike a linked list which is O(N).
If you google “circular buffer” there will be loads of diagrams that make it really obvious how it works.