public class UniqueStack<T> extends Object implements Iterable<T>
ResourceStack
represents a LIFO stack of unique objects (resources).
An attempt to insert on a stack an object that is already there will fail and result with a
method push(Object)
returning false.
All provided operations (pop()
and push(Object)
) are done in average constant
time.
This class is iterable
Constructor and Description |
---|
UniqueStack() |
Modifier and Type | Method and Description |
---|---|
boolean |
isEmpty()
Returns
true if this stack contains no elements. |
Iterator<T> |
iterator() |
T |
pop()
Removes last added object from the stack.
|
boolean |
push(T object)
Add an object to a stack.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public boolean push(T object)
object
- to be added. If it is null
a NullPointerException
will be thrown.public T pop()
NoSuchElementException
- - if the stack is emptypublic boolean isEmpty()
true
if this stack contains no elements.true
if this stack contains no elements.Copyright © 2010–2017 Google. All rights reserved.