public class IntStack extends IntArrayList
| Constructor and Description |
|---|
IntStack()
Constructs a new empty IntStack.
|
IntStack(int initialCapacity)
Constructs an empty stack with the specified initial capacity and
with its capacity increment equal to zero.
|
IntStack(int initialCapacity,
int capacityIncrement)
Constructs an empty stack with the specified initial capacity and
capacity increment.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
empty()
Tests if this stack is empty.
|
int |
peek()
Looks at the object at the top of this stack without removing it
from the stack.
|
int |
peek(int n)
Peeks at n positions from the top of the stack.
|
int |
pop()
Removes the integer at the top of this stack and returns it.
|
int |
push(int item)
Pushes an item onto the top of this stack.
|
int |
replace(int n,
int e)
Replaces the element at n positions from the top of the stack
with a new one; returns the old element.
|
int |
search(int n)
Returns the 1-based position wherethe specified int is on this
stack.
|
java.lang.String |
toString()
Returns a string representation of this Stack.
|
add, add, addAll, addAll, addAll, addAll, addElement, capacity, clear, clear, clone, contains, containsAll, containsAll, copyInto, elementAt, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, removeAll, removeAll, removeAllElements, removeAllFirst, removeAllFirst, removeElement, removeElementAt, removeIndex, removeRange, retainAll, set, setElementAt, setIncrementFactor, setLast, setSize, size, toArray, trimToSizepublic IntStack()
public IntStack(int initialCapacity,
int capacityIncrement)
initialCapacity - the initial capacity of the stack.capacityIncrement - amount by which the capacity is increased on overflow.java.lang.IllegalArgumentException - if the specified initial capacity is negative.public IntStack(int initialCapacity)
initialCapacity - the initial capacity of the stack.java.lang.IllegalArgumentException - if the specified initial capacity is negative.public final int push(int item)
item - the item to be pushed onto this stack.public final int pop()
java.lang.ArrayIndexOutOfBoundsException - if this stack is empty.public final int peek()
java.lang.ArrayIndexOutOfBoundsException - if this stack is empty.public final int peek(int n)
n - the offset from the top (0 -> top, 1 -> top-1,...)java.lang.ArrayIndexOutOfBoundsException - if index out of range.public final int replace(int n,
int e)
n - the offset from the top (0 -> top, 1 -> top-1,...)e - the new elementjava.lang.ArrayIndexOutOfBoundsException - if index out of range.public final boolean empty()
public final int search(int n)
n - the desired int.public java.lang.String toString()
toString in class IntArrayList