Stack.java

Download
1/*2 * Stack.java3 * 4 * Computer Science S-22, Harvard University5 */6 7/*8 * A generic interface that defines a simple ADT for a stack of9 * objects of a particular type.10 */11public interface Stack<T> {12    /* 13     * adds the specified item to the top of the stack.  Returns false14     * if the list is full, and true otherwise.15     */16    boolean push(T item);17 18    /* 19     * removes the item at the top of the stack and returns a20     * reference to the removed object.  Returns null is the stack is21     * empty.22     */23    T pop();24 25    /* 26     * returns a reference to the item at the top of the stack without27     * removing it. Returns null is the stack is empty.28     */29    T peek();30 31    /* returns true if the stack is empty, and false otherwise */32    boolean isEmpty();33 34    /* returns true if the stack is full, and false otherwise */35    boolean isFull();36}