net.cscott.jutil
public class UniqueStack<E> extends UniqueVector<E>
UniqueStack
class represents a last-in-first-out
stack of unique objects.
Conforms to the JDK 1.2 Collections API.
Version: $Id: UniqueStack.java,v 1.1 2003/03/20 01:58:20 cananian Exp $
Constructor Summary | |
---|---|
UniqueStack() Creates a UniqueStack . | |
<T extends E> | UniqueStack(Collection<T> c) Constructs a UniqueStack containing the elements of
the specified Collection , in the order they are returned
by the collection's iterator in LIFO order. |
Method Summary | |
---|---|
boolean | empty()
Tests if this stack is empty. |
E | peek()
Looks at the object at the top of this stack without removing it
from the stack. |
E | pop()
Removes the object at the top of this stack and returns that
object as the value of this function. |
void | push(E item)
Pushes an item onto the top of this stack, if it is unique.
|
int | search(Object o)
Returns where an object is on this stack. |
UniqueStack
.UniqueStack
containing the elements of
the specified Collection
, in the order they are returned
by the collection's iterator in LIFO order. That is, the first
item returned by the collection iterator will be at the bottom of
the stack, and thus last to be popped. Duplicate elements in
c
are skipped.Returns: true
if this stack is empty;
false
otherwise.
Returns: the object at the top of this stack.
Throws: EmptyStackException if this stack is empty.
Returns: The object at the top of this stack.
Throws: EmptyStackException if this empty.
Parameters: item the item to be pushed onto 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.