Interface Stack<T>

Type Parameters:
T - The type of data that the stack stores.
All Known Implementing Classes:
MysteryStackImplementation

public interface Stack<T>

An interface for the Stack ADT.


Method Summary
 void clear()
          Removes all items from the stack.
 boolean isEmpty()
          Returns true if the stack is empty.
 T peek()
          Returns the item on top of the stack, without removing it.
 T pop()
          Removes the item from the top of this stack, and returns it.
 void push(T item)
          Adds an item to the top of this stack.
 

Method Detail

push

void push(T item)
Adds an item to the top of this stack.

Parameters:
item - The item to add.

pop

T pop()
Removes the item from the top of this stack, and returns it. Note that some implementations may throw an EmptyStackException when the stack is empty, rather than returning a sentinel value.

Returns:
the item at the top of the stack, or null if empty.

peek

T peek()
Returns the item on top of the stack, without removing it. Note that some implementations may throw an EmptyStackException when the stack is empty, rather than returning a sentinel value.

Returns:
the item at the top of the stack, or null if empty.

isEmpty

boolean isEmpty()
Returns true if the stack is empty.


clear

void clear()
Removes all items from the stack.