Program defines the methods enqueueHead and dequeueHead. The latter is trivial to implement--it simply calls the dequeue method inherited from the QueueAsArray class.
The enqueueHead method takes a single argument which is the object to be added to the head of the deque. The enqueueHead method first checks that the deque is not full--a ContainerFullException exception is thrown when the deque is full. Next, the position at which to insert the new element is determined by decreasing the head field by one modulo the length of the array. Finally, the object to be enqueued is put into the array at the correct position and the count is adjusted accordingly. Under normal circumstances (i.e., when the exception is not thrown), the running time of enqueueHead is O(1).