Package org.jfree.util
Class FastStack
java.lang.Object
org.jfree.util.FastStack
- All Implemented Interfaces:
Serializable
,Cloneable
A very simple unsynchronized stack. This one is faster than the
java.util-Version.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the stack.clone()
Returns a clone of the stack.get
(int index) Returns the item at the specified slot in the stack.boolean
isEmpty()
Returnstrue
if the stack is empty, andfalse
otherwise.peek()
Returns the object at the top of the stack without removing it.pop()
Removes and returns the object from the top of the stack.void
Pushes an object onto the stack.int
size()
Returns the number of elements in the stack.
-
Field Details
-
contents
-
size
private int size -
initialSize
private int initialSize
-
-
Constructor Details
-
FastStack
public FastStack()Creates a new empty stack. -
FastStack
public FastStack(int size) Creates a new empty stack with the specified initial storage size.- Parameters:
size
- the initial storage elements.
-
-
Method Details
-
isEmpty
public boolean isEmpty()Returnstrue
if the stack is empty, andfalse
otherwise.- Returns:
- A boolean.
-
size
public int size()Returns the number of elements in the stack.- Returns:
- The element count.
-
push
Pushes an object onto the stack.- Parameters:
o
- the object.
-
peek
Returns the object at the top of the stack without removing it.- Returns:
- The object at the top of the stack.
-
pop
Removes and returns the object from the top of the stack.- Returns:
- The object.
-
clone
Returns a clone of the stack. -
clear
public void clear()Clears the stack. -
get
Returns the item at the specified slot in the stack.- Parameters:
index
- the index.- Returns:
- The item.
-