previous | index | next

A Better Queue Representation

Suppose we relax the invariant and allow the queue to start at any point in the cells vector.

Then the header vector needs to also record the position number of the start of the queue (where the head is):

Here, 5 has been dequeued, with the size decremented and the start position changed.

No shifting of remaining elements is needed.


previous | index | next