org.jwarp.util
Class Stack

java.lang.Object
  |
  +--org.jwarp.util.Stack

public final class Stack
extends java.lang.Object

This is a simple stack. I would have liked to use java.util.Stack, but I need a stack that returns "null" when the Stack is empty, rather than throwing an exception.

Author:
Anatole Tresch

Field Summary
protected  java.util.LinkedList stack
          The underlying linked list
 
Constructor Summary
Stack()
           
 
Method Summary
 void clear()
          Clear the stack (removes all elements)
 boolean isEmpty()
          Return if the stack is empty
 java.lang.Object pop()
          Pops an object from the stacks
 void push(java.lang.Object o)
          Push a new element onto the stack.
 int size()
          Get the current stack size
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stack

protected java.util.LinkedList stack
The underlying linked list
Constructor Detail

Stack

public Stack()
Method Detail

push

public void push(java.lang.Object o)
Push a new element onto the stack.
Parameters:
o - The new object

pop

public java.lang.Object pop()
Pops an object from the stacks
Returns:
The popped object or null

size

public int size()
Get the current stack size
Returns:
The stack size

isEmpty

public boolean isEmpty()
Return if the stack is empty
Returns:
true if the stack contains no elements

clear

public void clear()
Clear the stack (removes all elements)

©   O R C A   S y s t e m s