ArrayDeque
Class
Deque
interface presented in Lecture 5.
checkCapacity
method, or whatever you introduced for your
capacity management back in Lab 02, and you need to resize as needed)
first = (first + 1) % capacity
(and similarly for rear) is fine; however, when decrementing, the variables may go negative (to -1 from 0) and Java's modulo operator might not act the way
you expect, so when decrementing, you should use an explicit conditional rather than the %
operator, e.g.:
front--; if (front < 0) front = capacity()-1;
CollectionException
class,
ArrayDeque
implementation.)
ArrayDequeDemo
class is the one you need to launch (i.e., the one containing the main
method for the app).