preditor
Class CMStack<E>

java.lang.Object
  extended by preditor.CMStack<E>

public class CMStack<E>
extends java.lang.Object

A simple stack. Holds generic objects. Specifically intended for the Preditor package within the Campus Model project.

Author:
chasmand

Field Summary
 java.util.LinkedList<E> stack
           
 
Constructor Summary
CMStack()
          Constructs a new stack of type E.
 
Method Summary
 boolean isEmpty()
          Tests for emptiness of modelStack.
 E peek()
          Peeks at top model in stack, without removing it.
 E pop()
          Pops the model off the top of the stack.
 void print()
          Prints the current stack.
 E push(E e)
          Adds a new model to the top of the stack.
 int size()
          Return the size of the stack.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stack

public java.util.LinkedList<E> stack
Constructor Detail

CMStack

public CMStack()
Constructs a new stack of type E.

Method Detail

push

public E push(E e)
Adds a new model to the top of the stack.

Parameters:
e - item to be added
Returns:
the recently added model

pop

public E pop()
Pops the model off the top of the stack.

Returns:
top entry or null if empty stack

peek

public E peek()
Peeks at top model in stack, without removing it.

Returns:
top of stack

isEmpty

public boolean isEmpty()
Tests for emptiness of modelStack.

Returns:
true if empty; false otherwise

size

public int size()
Return the size of the stack. Added by Henry Gross.

Returns:
the size of the internal stack

print

public void print()
Prints the current stack. (Mostly for testing purposes.)