Class FastStack<T>
- java.lang.Object
-
- org.pentaho.reporting.libraries.base.util.FastStack<T>
-
- All Implemented Interfaces:
Serializable
,Cloneable
public final class FastStack<T> extends Object implements Serializable, Cloneable
A very simple unsynchronized stack. This one is faster than the java.util-Version, which is based on the synchronized java.util.Vector class.- Author:
- Thomas Morgner
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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()
-
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
Checks whether the stack is empty.- Returns:
- true, if the stack is empty, false otherwise.
-
size
public int size()
Returns the number of elements in the stack.- Returns:
- the stack size.
-
push
public void push(T o)
Pushes a new object on the stack. Null-references are allowed.- Parameters:
o
- the object, maybe null.
-
peek
public T peek()
Loads the top-most element from the stack, without removing it from the stack.- Returns:
- the top-most object.
- Throws:
EmptyStackException
- if the stack is empty.
-
pop
public T pop()
Loads the top-most element from the stack and removes it from the stack at the same time.- Returns:
- the top-most object.
- Throws:
EmptyStackException
- if the stack is empty.
-
clear
public void clear()
Removes all contents from the stack.
-
get
public T get(int index)
Returns the element from the stack at the given index-position.- Parameters:
index
- the element's index.- Returns:
- the object.
- Throws:
IndexOutOfBoundsException
- if the index given is greater than the number of objects in the stack.
-
-