|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jasn.util.Stack
The class represents a last-in-first-out (LIFO) stack of long
values. The usual push and pop operations are
provided, as well as a method to peek at the top item on the
stack and a method to test whether the stack is empty.
Each Stack instance has a capacity. The capacity is the size of the array used to store the elements in the stack. It is always at least as large as the stack size. As elements are added to a Stack, its capacity grows automatically. The details of the growth policy are not specified beyond the fact that adding an element has constant amortized time cost.
An application can increase the capacity of a Stack instance before adding a large number of elements using the ensureCapacity operation. This may reduce the amount of incremental reallocation.
When a stack is first created, it contains no items.
| Constructor Summary | |
Stack()
Creates an empty stack containing long values. |
|
Stack(int initialCapacity)
Constructs an empty list with the specified initial capacity. |
|
| Method Summary | |
void |
clear()
Removes all of the elements from this stack. |
void |
ensureCapacity(int minCapacity)
Increases the capacity of this ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument. |
boolean |
isEmpty()
Tests wether this stack is empty. |
Object |
peek()
Looks at the value at the top of this stack without removing it from the stack. |
Object |
pop()
Removes the value at the top of this stack and returns that value. |
void |
push(Object o)
Pushes the specified long value onto the top of this stack. |
int |
size()
Returns the number of elements in this stack. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Stack(int initialCapacity)
initialCapacity - the initial capacity of the list.
IllegalArgumentException - if the specified initial capacity
is negativepublic Stack()
long values.
| Method Detail |
public void push(Object o)
long value onto the top of this stack.
public Object pop()
long value at the top of this stack.
EmptyStackException - if this stack is empty.public Object peek()
long at the top of this stack.
EmptyStackException - if this stack is empty.public boolean isEmpty()
true if and only if this stack contains no items;
false otherwise.public int size()
public void ensureCapacity(int minCapacity)
minCapacity - the desired minimum capacity.public void clear()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||