Stack Interface


//----------------------------------------------------------------------------
// StackInterface.java           by Dale/Joyce/Weems                 Chapter 2
//
// Interface for a class that implements a stack of <T>.
// A stack is a last-in, first-out structure.
//----------------------------------------------------------------------------
package ch02.stacks;

public interface StackInterface<T> {
   void push(T element) throws StackOverflowException;
   // Throws StackOverflowException if this stack is full,
   // otherwise places element at the top of this stack.

   void pop() throws StackUnderflowException;
   // Throws StackUnderflowException if this stack is empty,
   // otherwise removes top element from this stack.

   T top() throws StackUnderflowException;
   // Throws StackUnderflowException if this stack is empty,
   // otherwise returns top element of this stack.

   boolean isEmpty();
   // Returns true if this stack is empty, otherwise returns false.

   boolean isFull();
   // Returns true if this stack is full, otherwise returns false.
}


Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2017