org.jfree.util

Class FastStack

public final class FastStack extends Object implements Serializable, Cloneable

A very simple unsynchronized stack. This one is faster than the java.util-Version.

Author: Thomas Morgner

Constructor Summary
FastStack()
Creates a new empty stack.
FastStack(int size)
Creates a new empty stack with the specified initial storage size.
Method Summary
voidclear()
Clears the stack.
Objectclone()
Returns a clone of the stack.
Objectget(int index)
Returns the item at the specified slot in the stack.
booleanisEmpty()
Returns true if the stack is empty, and false otherwise.
Objectpeek()
Returns the object at the top of the stack without removing it.
Objectpop()
Removes and returns the object from the top of the stack.
voidpush(Object o)
Pushes an object onto the stack.
intsize()
Returns the number of elements in the stack.

Constructor Detail

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 Detail

clear

public void clear()
Clears the stack.

clone

public Object clone()
Returns a clone of the stack.

Returns: A clone.

get

public Object get(int index)
Returns the item at the specified slot in the stack.

Parameters: index the index.

Returns: The item.

isEmpty

public boolean isEmpty()
Returns true if the stack is empty, and false otherwise.

Returns: A boolean.

peek

public Object peek()
Returns the object at the top of the stack without removing it.

Returns: The object at the top of the stack.

pop

public Object pop()
Removes and returns the object from the top of the stack.

Returns: The object.

push

public void push(Object o)
Pushes an object onto the stack.

Parameters: o the object.

size

public int size()
Returns the number of elements in the stack.

Returns: The element count.