public class ArrayStack<T> extends Object implements Stack<T>, Serializable
Stack
interface that is backed by an
array.Stack.StackListenerList<T>
Constructor and Description |
---|
ArrayStack() |
ArrayStack(Comparator<T> comparator) |
ArrayStack(int capacity) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all elements from the collection.
|
void |
ensureCapacity(int capacity) |
Comparator<T> |
getComparator()
Returns the collection's sort order.
|
int |
getDepth()
Returns the stack depth.
|
ListenerList<StackListener<T>> |
getStackListeners()
Returns the stack listener list.
|
boolean |
isEmpty()
Tests the emptiness of the stack.
|
Iterator<T> |
iterator() |
T |
peek()
Returns the item on top of the stack without removing it from the stack.
|
T |
pop()
Removes the top item from the stack and returns it.
|
void |
push(T item)
"Pushes" an item onto the stack.
|
void |
setComparator(Comparator<T> comparator)
Sets the collection's sort order, re-ordering the collection's contents
and ensuring that new entries preserve the sort order.
|
public ArrayStack()
public ArrayStack(Comparator<T> comparator)
public ArrayStack(int capacity)
public void push(T item)
Stack
public T pop()
Stack
public T peek()
Stack
public void clear()
Collection
clear
in interface Collection<T>
public boolean isEmpty()
Stack
public int getDepth()
Stack
public void ensureCapacity(int capacity)
public Comparator<T> getComparator()
Collection
getComparator
in interface Collection<T>
Collection.setComparator(Comparator)
public void setComparator(Comparator<T> comparator)
Collection
Calling this method more than once with the same comparator will re-sort the collection.
setComparator
in interface Collection<T>
comparator
- The comparator used to order elements in the collection, or null if the
collection is unsorted.public ListenerList<StackListener<T>> getStackListeners()
Stack
getStackListeners
in interface Stack<T>