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>
-
UniqueStack()
- Creates a
UniqueStack
.
-
empty()
- Tests if this stack is empty.
-
peek()
- Looks at the object at the top of this stack without removing it
from the stack.
-
pop()
- Removes the object at the top of this stack and returns that
object as the value of this function.
-
pull()
-
-
push(Object)
-
Pushes an item onto the top of this stack, if it is unique.
-
search(Object)
- Returns where an object is on this stack.
UniqueStack
public UniqueStack()
- Creates a
UniqueStack
.
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.
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.
pull
public Object pull()
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.
empty
public boolean empty()
- Tests if this stack is empty.
- Returns:
-
true
if this stack is empty;
false
otherwise.
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