3 ms·
Why would you need to "wrap around" an array? I guess it's helpful if you use an array to represent a cyclic group, but how often this happens in practice? An
by IlliOnato 6y ago
Why would you need to "wrap around" an array?
I guess it's helpful if you use an array to represent a cyclic group, but how often this happens in practice?
And when you need the number of the last element, you need to do A[n-1], which is "less helpful", I guess.
- raverbashing 6y agoI think both those cases happen with a certain frequency, yes, your last element is a bit trickier, though in Python it is represented by A[-1] (so that would turn into A[len-1]) Yeah, maybe there's no fundamental advantage, one would have to check the most common cases. > Why would you need to "wrap around" an array? Ring buffers
- secondcoming 6y agoRingbuffers are used all over