weiss.nonstandard
Interface Stack<AnyType>

All Known Implementing Classes:
ArrayStack, ListStack

public interface Stack<AnyType>

Protocol for stacks.


Method Summary
 boolean isEmpty()
          Test if the stack is logically empty.
 void makeEmpty()
          Make the stack logically empty.
 void pop()
          Remove the most recently inserted item from the stack.
 void push(AnyType x)
          Insert a new item into the stack.
 AnyType top()
          Get the most recently inserted item in the stack.
 AnyType topAndPop()
          Return and remove the most recently inserted item from the stack.
 

Method Detail

push

void push(AnyType x)
Insert a new item into the stack.

Parameters:
x - the item to insert.

pop

void pop()
Remove the most recently inserted item from the stack.

Throws:
UnderflowException - if the stack is empty.

top

AnyType top()
Get the most recently inserted item in the stack. Does not alter the stack.

Returns:
the most recently inserted item in the stack.
Throws:
UnderflowException - if the stack is empty.

topAndPop

AnyType topAndPop()
Return and remove the most recently inserted item from the stack.

Returns:
the most recently inserted item in the stack.
Throws:
UnderflowException - if the stack is empty.

isEmpty

boolean isEmpty()
Test if the stack is logically empty.

Returns:
true if empty, false otherwise.

makeEmpty

void makeEmpty()
Make the stack logically empty.