net.datastructures
Interface Stack<E>

All Known Implementing Classes:
ArrayStack, NodeStack

public interface Stack<E>

Interface for a stack: a collection of objects that are inserted and removed according to the last-in first-out principle. This interface includes the main methods of java.util.Stack.

Author:
Roberto Tamassia, Michael Goodrich
See Also:
EmptyStackException

Method Summary
 boolean isEmpty()
          Return whether the stack is empty.
 E pop()
          Remove the top element from the stack.
 void push(E element)
          Insert an element at the top of the stack.
 int size()
          Return the number of elements in the stack.
 E top()
          Inspect the element at the top of the stack.
 

Method Detail

size

int size()
Return the number of elements in the stack.

Returns:
number of elements in the stack.

isEmpty

boolean isEmpty()
Return whether the stack is empty.

Returns:
true if the stack is empty, false otherwise.

top

E top()
      throws EmptyStackException
Inspect the element at the top of the stack.

Returns:
top element in the stack.
Throws:
EmptyStackException - if the stack is empty.

push

void push(E element)
Insert an element at the top of the stack.

Parameters:
element - to be inserted.

pop

E pop()
      throws EmptyStackException
Remove the top element from the stack.

Returns:
element removed.
Throws:
EmptyStackException - if the stack is empty.