ListStack
Class Stack

java.lang.Object
  |
  +--ListStack.Stack

public class Stack
extends java.lang.Object

Stack models a stack data structure (using a linked list)


Constructor Summary
Stack()
          Constructor Stack creates an empty stack.
 
Method Summary
 boolean isEmpty()
          isEmpty states whether the stack has 0 elements.
 java.lang.Object pop()
          pop removes the most recently added element
 void push(java.lang.Object ob)
          push inserts a new element onto the stack
 java.lang.Object top()
          top returns the identity of the most recently added element
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Stack

public Stack()
Constructor Stack creates an empty stack.
Method Detail

push

public void push(java.lang.Object ob)
push inserts a new element onto the stack
Parameters:
ob - - the element to be added

pop

public java.lang.Object pop()
pop removes the most recently added element
Returns:
the element removed from the stack
Throws:
java.lang.RuntimeException - if stack is empty

top

public java.lang.Object top()
top returns the identity of the most recently added element
Returns:
the element
Throws:
java.lang.RuntimeException - if stack is empty

isEmpty

public boolean isEmpty()
isEmpty states whether the stack has 0 elements.
Returns:
whether the stack has no elements