edu.ksu.cis.viewer
Class Stack

java.lang.Object
  extended byedu.ksu.cis.viewer.Stack
All Implemented Interfaces:
Cloneable

public final class Stack
extends Object
implements Cloneable

A stack built from an immutable ConsList. Using an immutable structure for the underlying storage allows a shallow clone to be sufficient.

Author:
Rod Howell (howell@cis.ksu.edu)

Constructor Summary
Stack()
          Constructs an empty Stack.
 
Method Summary
 Object clone()
          Returns a clone of this stack.
 boolean empty()
          Returns true if the stack is empty.
 Object pop()
          Removes the Object from the top of the stack and returns it.
 void push(Object obj)
          Pushes the given Object onto the top of the stack.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Stack

public Stack()
Constructs an empty Stack.

Method Detail

push

public void push(Object obj)
Pushes the given Object onto the top of the stack.


pop

public Object pop()
           throws EmptyStackException
Removes the Object from the top of the stack and returns it.

Throws:
EmptyStackException - If the stack is empty.

empty

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


clone

public Object clone()
Returns a clone of this stack. Because the underlying structure is immutable, a shallow clone is performed.