Hacker News new | ask | show | jobs
by kadoban 2474 days 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).
1 comments

Thanks! DEQ implementation with circular buffer. :)

Edit: should have thought of that. Brain fart—-long day at work.

Exactly! I really like this stuff, little clever ways to skip effort. Data structures and algos don't get enough love :)