org.gjt.rec.util
Class ListStack

java.lang.Object
  |
  +--org.gjt.rec.util.ListStack
All Implemented Interfaces:
Stack

public final class ListStack
extends Object
implements Stack

A implementation of the Stack interface that uses a list to store its elements.

Author:
Neil Stockbridge
See Also:
Stack, List

Field Summary
static String REVISION
           
 
Constructor Summary
ListStack()
          Constructs a new ListStack that will use the default list type.
ListStack(List list)
          Constructs a new ListStack with a particular List.
 
Method Summary
 void clear()
          Removes all elements from this stack, making it empty.
 boolean isEmpty()
           
 Object pop()
          Removes the element on the top of this stack.
 void push(Object element)
          Pushes a particular element on to the top of this stack.
 int size()
           
 Object top()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values
Constructor Detail

ListStack

public ListStack()
Constructs a new ListStack that will use the default list type.


ListStack

public ListStack(List list)
Constructs a new ListStack with a particular List.

Parameters:
list - the list to use to store the elements for this stack.
Throws:
NullPointerException - if the argument supplied for the list is null.
Method Detail

size

public int size()
Specified by:
size in interface Stack
Returns:
the number of elements on this stack.

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Stack
Returns:
true if there are no elements on this stack.

top

public Object top()
Specified by:
top in interface Stack
Returns:
the element on the top of this stack

push

public void push(Object element)
Description copied from interface: Stack
Pushes a particular element on to the top of this stack.

Specified by:
push in interface Stack
Parameters:
element - the element to push on to the top of this stack.

pop

public Object pop()
Description copied from interface: Stack
Removes the element on the top of this stack.

Specified by:
pop in interface Stack
Returns:
the element that was removed.

clear

public void clear()
Description copied from interface: Stack
Removes all elements from this stack, making it empty.

Specified by:
clear in interface Stack