3 ms·
You've answered your own question implicitly. The address of the starting and ending element can change. You just define yourself where in the backing array the
by kadoban 7y ago
You've answered your own question implicitly. The address of the starting and ending element can change. You just define yourself where in the backing array the start/end are, and let them wrap around (use modular arithmetic for the indexes).
- panda88888 7y agoThanks! DEQ implementation with circular buffer. :) Edit: should have thought of that. Brain fart—-long day at work.
- kadoban 7y agoExactly! I really like this stuff, little clever ways to skip effort. Data structures and algos don't get enough love :)