dataStructures
Class LinkedStack

java.lang.Object
  |
  +--dataStructures.LinkedStack

public class LinkedStack
extends java.lang.Object
implements Stack


Field Summary
protected  dataStructures.ChainNode topNode
           
 
Constructor Summary
LinkedStack()
           
LinkedStack(int initialCapacity)
          create an empty stack
 
Method Summary
 boolean empty()
           
static void main(java.lang.String[] args)
          test program
 java.lang.Object peek()
           
 java.lang.Object pop()
          remove top element of stack and return it
 void push(java.lang.Object theElement)
          add theElement to the top of the stack
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

topNode

protected dataStructures.ChainNode topNode
Constructor Detail

LinkedStack

public LinkedStack(int initialCapacity)
create an empty stack

LinkedStack

public LinkedStack()
Method Detail

empty

public boolean empty()
Specified by:
empty in interface Stack
Returns:
true iff stack is empty

peek

public java.lang.Object peek()
Specified by:
peek in interface Stack
Returns:
top element of stack
Throws:
java.util.EmptyStackException - when the stack is empty

push

public void push(java.lang.Object theElement)
add theElement to the top of the stack
Specified by:
push in interface Stack

pop

public java.lang.Object pop()
remove top element of stack and return it
Specified by:
pop in interface Stack
Throws:
java.util.EmptyStackException - when the stack is empty

main

public static void main(java.lang.String[] args)
test program