edu.trinity.cs.bmassing.adt1
Interface SimpleStack<E>

All Known Implementing Classes:
FixedArrayStack

public interface SimpleStack<E>

Interface for stacks. (This provides a common interface for potentially different implementations, but you could certainly write a stack class without it.)


Method Summary
 boolean empty()
          Tells whether stack is empty.
 E pop()
          Pops an element from the stack.
 void push(E x)
          Pushes an element onto the stack.
 E top()
          Gets the top element of the stack (but does not remove it).
 

Method Detail

empty

boolean empty()
Tells whether stack is empty.

Returns:
true if stack is empty, false otherwise

push

void push(E x)
          throws StackFullException
Pushes an element onto the stack.

Parameters:
x - element to add
Throws:
StackFullException - if stack is already full

pop

E pop()
      throws StackEmptyException
Pops an element from the stack.

Returns:
(former) top element of stack
Throws:
StackEmptyException - if stack is empty

top

E top()
      throws StackEmptyException
Gets the top element of the stack (but does not remove it).

Returns:
top element of stack
Throws:
StackEmptyException - if stack is empty