public final class FastStack<T> extends Object implements Serializable, Cloneable
Constructor and 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 and Description |
---|---|
void |
clear()
Removes all contents from the stack.
|
FastStack<T> |
clone()
Creates a shallow copy of the stack.
|
T |
get(int index)
Returns the element from the stack at the given index-position.
|
boolean |
isEmpty()
Checks whether the stack is empty.
|
T |
peek()
Loads the top-most element from the stack, without removing it from the stack.
|
T |
pop()
Loads the top-most element from the stack and removes it from the stack at the same time.
|
void |
push(T o)
Pushes a new object on the stack.
|
int |
size()
Returns the number of elements in the stack.
|
String |
toString() |
public FastStack()
public FastStack(int size)
size
- the initial size and growth.public boolean isEmpty()
public int size()
public void push(T o)
o
- the object, maybe null.public T peek()
EmptyStackException
- if the stack is empty.public T pop()
EmptyStackException
- if the stack is empty.public void clear()
public T get(int index)
index
- the element's index.IndexOutOfBoundsException
- if the index given is greater than the number of objects in the stack.