weiss.util
Class Stack<AnyType>

java.lang.Object
  extended by weiss.util.Stack<AnyType>
All Implemented Interfaces:
java.io.Serializable

public class Stack<AnyType>
extends java.lang.Object
implements java.io.Serializable

Stack class. Unlike java.util.Stack, this is not extended from Vector. This is the minimum respectable set of operations.

See Also:
Serialized Form

Constructor Summary
Stack()
          Constructs an empty stack.
 
Method Summary
 void clear()
           
 boolean isEmpty()
          Tests if stack is empty.
 AnyType peek()
          Returns item from the top of the stack.
 AnyType pop()
          Removes and returns item from the top of the stack.
 AnyType push(AnyType x)
          Adds an item to the top of the stack.
 int size()
          Returns the size of the stack.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Stack

public Stack()
Constructs an empty stack.

Method Detail

push

public AnyType push(AnyType x)
Adds an item to the top of the stack.

Parameters:
x - the item to add.
Returns:
the item added.

pop

public AnyType pop()
Removes and returns item from the top of the stack.

Returns:
the former top item.
Throws:
EmptyStackException - if stack is empty.

peek

public AnyType peek()
Returns item from the top of the stack.

Returns:
the top item.
Throws:
EmptyStackException - if stack is empty.

isEmpty

public boolean isEmpty()
Tests if stack is empty.

Returns:
true if the stack is empty; false otherwise.

size

public int size()
Returns the size of the stack.

Returns:
the size of the stack.

clear

public void clear()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object