/* Stack.java ** An instance of a class that implements this interface represents a stack, ** which is a container having a last-in-first-out (LIFO) arrival/departure ** pattern. ** Author: R. McCloskey */ public interface Stack { // observers // --------- /* Returns the number of items on the stack. */ int sizeOf(); /* Reports whether or not there are no items on the stack. */ boolean isEmpty(); /* Returns the capacity of the stack (i.e., the maximum # of items ** that can occupy it at any one time). */ int capacityOf(); /* Returns (a reference to) the item at the top of the stack. ** pre: !isEmpty() */ T topOf(); // mutators // -------- /* Places (a reference to) the specified item on top of the stack. ** pre: sizeOf() < capacityOf() */ void push( T item ); /* Removes the item at the top of the stack and returns (a reference to) it. ** pre: !isEmpty() */ T pop(); /* Makes the stack empty. */ void clear(); }