|
JUtil | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> java.util.AbstractList<E> net.cscott.jutil.UniqueVector<E> net.cscott.jutil.UniqueStack<E>
public class UniqueStack<E>
The UniqueStack
class represents a last-in-first-out
stack of unique objects.
Conforms to the JDK 1.2 Collections API.
Field Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
UniqueStack()
Creates a UniqueStack . |
|
UniqueStack(Collection<? extends E> 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. |
Methods inherited from class net.cscott.jutil.UniqueVector |
---|
add, add, addElement, capacity, clear, clone, contains, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, removeAllElements, removeElement, removeElementAt, set, setElementAt, size, toArray, toArray, toString, trimToSize |
Methods inherited from class java.util.AbstractList |
---|
addAll, iterator, listIterator, listIterator, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, containsAll, remove, removeAll, retainAll |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Set |
---|
addAll, containsAll, iterator, remove, removeAll, retainAll |
Methods inherited from interface java.util.List |
---|
addAll, containsAll, remove, removeAll, retainAll |
Constructor Detail |
---|
public UniqueStack()
UniqueStack
.
public UniqueStack(Collection<? extends E> c)
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.
Method Detail |
---|
public void push(E item)
item
- the item to be pushed onto this stack.public E pop()
EmptyStackException
- if this empty.public E peek()
EmptyStackException
- if this stack is empty.public boolean empty()
true
if this stack is empty;
false
otherwise.public int search(Object o)
o
- the desired object.
-1
indicates that the
object is not on the stack.
|
JUtil | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |