java.io.Serializable, java.lang.Cloneablepublic final class FastStack
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
| Constructor | Description |
|---|---|
FastStack() |
Creates a new stack with an initial size and growth of 10 items.
|
FastStack(int size) |
Creates a new stack with an initial size and growth as specified.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
clear() |
Removes all contents from the stack.
|
java.lang.Object |
clone() |
Creates a shallow copy of the stack.
|
java.lang.Object |
get(int index) |
Returns the element from the stack at the given index-position.
|
boolean |
isEmpty() |
Checks whether the stack is empty.
|
java.lang.Object |
peek() |
Loads the top-most element from the stack, without removing it from the stack.
|
java.lang.Object |
pop() |
Loads the top-most element from the stack and removes it from the stack at the same time.
|
void |
push(java.lang.Object o) |
Pushes a new object on the stack.
|
int |
size() |
Returns the number of elements in the stack.
|
public FastStack()
public FastStack(int size)
size - the initial size and growth.public boolean isEmpty()
public int size()
public void push(java.lang.Object o)
o - the object, maybe null.public java.lang.Object peek()
java.util.EmptyStackException - if the stack is empty.public java.lang.Object pop()
java.util.EmptyStackException - if the stack is empty.public java.lang.Object clone()
public void clear()
public java.lang.Object get(int index)
index - the element's index.java.lang.IndexOutOfBoundsException - if the index given is greater than the number of objects in the stack.