ewe.util
Class Stack

java.lang.Object
  extended byewe.util.Stack

public class Stack
extends Object


Constructor Summary
Stack()
          This constructor creates a new Stack, initially empty
 
Method Summary
 void clear()
           
 Object elementAt(int index)
           
 boolean empty()
          Tests if the stack is empty.
 Object peek()
          Returns the top Object on the stack without removing it.
 Object pop()
          Pops an item from the stack and returns it.
 Object push(Object item)
          Pushes an Object onto the top of the stack.
 int search(Object o)
          Returns the position of an Object on the stack, with the top most Object being at position 1, and each Object deeper in the stack at depth + 1.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Constructor Detail

Stack

public Stack()
This constructor creates a new Stack, initially empty

Method Detail

clear

public void clear()

push

public Object push(Object item)
Pushes an Object onto the top of the stack. This method is effectively the same as addElement(item).

Parameters:
item - the Object to push onto the stack
Returns:
the Object pushed onto the stack

pop

public Object pop()
Pops an item from the stack and returns it. The item popped is removed from the Stack.

Returns:
the Object popped from the stack
Throws:
EmptyStackException - if the stack is empty

peek

public Object peek()
Returns the top Object on the stack without removing it.

Returns:
the top Object on the stack
Throws:
EmptyStackException - if the stack is empty

empty

public boolean empty()
Tests if the stack is empty.

Returns:
true if the stack contains no items, false otherwise

search

public int search(Object o)
Returns the position of an Object on the stack, with the top most Object being at position 1, and each Object deeper in the stack at depth + 1.

Parameters:
o - The object to search for
Returns:
The 1 based depth of the Object, or -1 if the Object is not on the stack

size

public int size()

elementAt

public Object elementAt(int index)