net.grelf
Class Stack_<E>

java.lang.Object
  extended by net.grelf.Stack_<E>
All Implemented Interfaces:
java.io.Serializable, Stack<E>

public class Stack_<E>
extends java.lang.Object
implements Stack<E>, java.io.Serializable

A simple last-in-first-out (LIFO) stack, to a better OO design than Sun's one. This one has a LinkedList rather than subclassing Vector. It only exposes the behaviour that a stack should have.

See Also:
Serialized Form

Constructor Summary
Stack_()
          Construct an empty stack.
 
Method Summary
 boolean isEmpty()
          Tell whether the stack is empty.
 E peek()
          Look at last value without removing it.
 E pop()
          Get the last value, removing it from the stack.
 void push(E obj)
          Put a new last value onto the stack.
 java.lang.String toString()
          Get a String representation of the Stack
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Stack_

public Stack_()
Construct an empty stack.

Method Detail

isEmpty

public boolean isEmpty()
Tell whether the stack is empty.

Specified by:
isEmpty in interface Stack<E>

peek

public E peek()
Look at last value without removing it.

Specified by:
peek in interface Stack<E>

pop

public E pop()
Get the last value, removing it from the stack.

Specified by:
pop in interface Stack<E>

push

public void push(E obj)
Put a new last value onto the stack.

Specified by:
push in interface Stack<E>

toString

public java.lang.String toString()
Get a String representation of the Stack

Overrides:
toString in class java.lang.Object