I have a fixed size circular buffer (implemented as an array): upon initialization, the buffer gets filled with the specified maximum number of elements which allows the use
FWIW, you could always do a parallel array: i = next[i];
i = next[i];
But, really, I've always just done this: i++; if (i >= n) i = 0; OR i = (i+1) % n;
i++; if (i >= n) i = 0;
i = (i+1) % n;
Regardless, I'd be really surprised if this is ever a significant performance issue.