All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class harpoon.Util.UniqueStack

java.lang.Object
   |
   +----harpoon.Util.UniqueVector
           |
           +----harpoon.Util.UniqueStack

public class UniqueStack
extends UniqueVector
implements Worklist
The UniqueStack class represents a last-in-first-out stack of unique objects.

Version:
$Id: UniqueStack.java,v 1.3 1998/10/11 02:37:59 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>

Constructor Index

 o UniqueStack()
Creates a UniqueStack.

Method Index

 o empty()
Tests if this stack is empty.
 o peek()
Looks at the object at the top of this stack without removing it from the stack.
 o pop()
Removes the object at the top of this stack and returns that object as the value of this function.
 o pull()
 o push(Object)
Pushes an item onto the top of this stack, if it is unique.
 o search(Object)
Returns where an object is on this stack.

Constructors

 o UniqueStack
 public UniqueStack()
Creates a UniqueStack.

Methods

 o push
 public Object push(Object item)
Pushes an item onto the top of this stack, if it is unique. Otherwise, does nothing.

Parameters:
item - the item to be pushed onto this stack.
Returns:
the item argument.
 o pop
 public synchronized Object pop()
Removes the object at the top of this stack and returns that object as the value of this function.

Returns:
The object at the top of this stack.
Throws: EmptyStackException
if this empty.
 o pull
 public Object pull()
 o peek
 public synchronized Object peek()
Looks at the object at the top of this stack without removing it from the stack.

Returns:
the object at the top of this stack.
Throws: EmptyStackException
if this stack is empty.
 o empty
 public boolean empty()
Tests if this stack is empty.

Returns:
true if this stack is empty; false otherwise.
 o search
 public synchronized int search(Object o)
Returns where an object is on this stack.

Parameters:
o - the desired object.
Returns:
the distance from the top of the stack where the object is located; the return value -1 indicates that the object is not on the stack.

All Packages  Class Hierarchy  This Package  Previous  Next  Index