/* Deque.java ** An instance of an implementing class represents a double-ended queue, ** or deque, which combines the capabilities of a stack and a queue. ** That is, in a deque, elements can be inserted at both the front and ** the rear, and likewise removed from both the front and the rear. ** Only the elements at the front and at the rear can be observed. ** ** Author: R. McCloskey ** Date: March 2019 */ public interface Deque { // observers // --------- /* Reports whether or not this deque is empty (i.e., has no elements in it). */ boolean isEmpty(); /* Reports whether or not this deque is full, which means that an ** attempt to insert an item may fail. */ boolean isFull(); /* Reports how many items occupy this deque. */ int sizeOf(); /* Returns (a reference to) the item at the front of this deque. ** pre: !isEmpty() */ T frontOf(); /* Returns (a reference to) the item at the rear of this deque. ** pre: !isEmpty() */ T rearOf(); // mutators // -------- /* Removes the item at the front of this deque. ** pre: !isEmpty() */ void removeFront(); /* Removes the item at the rear of this deque. ** pre: !isEmpty() */ void removeRear(); /* Inserts the specified item at the front of this deque. */ void insertAtFront(T elem); /* Inserts the specified item at the rear of this deque. */ void insertAtRear(T elem); }