Data Structures ยท Queue ADT

A queue stored in a circular array

Enqueue and dequeue values and watch the C++ run one line at a time. The queue lives in a fixed array of 8 ints. front marks the head, where items leave, and rear marks the tail, where items join. Both move to the right and wrap from [7] back to [0].

Memory: int data[8]

front
rear
In the queue Old value still in memory, no longer in the queue Never written

Variables

What is happening

ReadyType a number and press enqueue(x).

Calls from main()

    ArrayQueue.cpp

      The % CAPACITY is what makes the array circular: after index 7 comes index 0. When the queue is empty and when it is full, rear sits just behind front, so count is how the code tells the two apart.