/** * Interface for a stack: a collection of objects * that are inserted and removed according to the * last-in first-out principle. * * @author Roberto Tamassia * @author Michael Goodrich * @see StackEmptyException */ public interface Stack { /** @return number of elements in the stack. */ public int size(); /** @return true if the stack is empty, false otherwise. */ public boolean isEmpty(); /** * @return top element in the stack. * @exception StackEmptyException if the stack is empty. */ public Object top(); /** * Insert an element at the top of the stack. * @param element element to be inserted. * @exception StackFullException if the stack is full. */ public void push (Object element); /** * Remove the top element from the stack. * @return element removed. * @exception StackEmptyException if the stack is empty. */ public Object pop(); }