Deprecated
use java. instead (available from Java 1.6)
java.util.Stack API that is based on an
ArrayList instead of a Vector, so it is not
synchronized to protect against multi-threaded access. The implementation
is therefore operates faster in environments where you do not need to
worry about multiple thread contention.
The removal order of an ArrayStack is based on insertion
order: The most recently added element is removed first. The iteration
order is not the same as the removal order. The iterator returns
elements from the bottom up.
Unlike Stack, ArrayStack accepts null entries.
Note
From version 4.0 onwards, this class does not implement the
removed Buffer interface anymore.
java.util.Stack
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Ensure serialization compatibility
|
| Access | Constructor and Description |
|---|---|
| public | |
| public | ArrayStack(final int
the initial size to use initialSize)Constructs a new empty |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public E | |
| public E | Returns: the n'th item on the stack, zero relativethe number of items down to go n)Returns the n'th item down (zero-relative) from the top of this stack without removing it. |
| public E | |
| public E | Returns: the item just pushedthe item to be added item)Pushes a new item onto the top of this stack. |
| public int | Returns: the 1-based depth into the stack of the object, or -1 if not foundthe object to be searched for object)Returns the one-based position of the distance from the top that the
specified object exists on this stack, where the top-most element is
considered to be at distance |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides java. Ensure serialization compatibility | |
| ArrayStack | back to summary |
|---|---|
| public ArrayStack() Constructs a new empty | |
| ArrayStack | back to summary |
|---|---|
| public ArrayStack(final int initialSize) Constructs a new empty
| |
| empty | back to summary |
|---|---|
| public boolean empty() Return
This method exists for compatibility with
| |
| peek | back to summary |
|---|---|
| public E peek() throws EmptyStackException Returns the top item off of this stack without removing it.
| |
| peek | back to summary |
|---|---|
| public E peek(final int n) throws EmptyStackException Returns the n'th item down (zero-relative) from the top of this stack without removing it.
| |
| pop | back to summary |
|---|---|
| public E pop() throws EmptyStackException Pops the top item off of this stack and return it.
| |
| push | back to summary |
|---|---|
| public E push(final E item) Pushes a new item onto the top of this stack. The pushed item is also
returned. This is equivalent to calling
| |
| search | back to summary |
|---|---|
| public int search(final Object object) Returns the one-based position of the distance from the top that the
specified object exists on this stack, where the top-most element is
considered to be at distance
| |