(Up to Resources
: Source Code Repository : Lists)
This source file is an implementation of the Queue class.
The class is implemented with templates, and the size is
determined dynamically at initialization (although the default is
For the templated class, the elements must have the operators >,
=, and < defined.
The actual amount of space allocated for the Queue will be one
more element than the defined maximum size. This is useful for
implementing the Queue in a circular method.
To understand the circular implementation, think of the array as
a circle. When an element is dequeued, the Queue doesn't
shift all of the elements forward to the start of the queue.
Instead, the class shifts the start of the queue back. Eventually,
the start of the queue will have shifted so far that the queue will
extend beyond the end of the array. This is where the circle comes
in. When the queue reachs the end of the array, it wraps around
to the beginning of the array.