FileDocCategorySizeDatePackage
FastStack.javaAPI DocGlassfish v2 API5155Fri May 04 22:32:10 BST 2007com.sun.enterprise.util.collection

FastStack

public class FastStack extends Object
The Stack class represents a last-in-first-out (LIFO) stack of objects. The implementation is backed by java.util.ArrayList. Unlike java.util.Stack, it does not extend class Vector and hence all methods in the stack are unsynchronized. The usual push and pop operations are provided, as well as a method to peek at the top item on the stack, a method to test for whether the stack is empty. When a stack is first created, it contains no items.

Fields Summary
private ArrayList
stack
Constructors Summary
public FastStack()
Create a stack with no elements in it.

    	stack = new ArrayList(4);
    
Methods Summary
public booleanempty()
Tests if this stack is empty.

return
true if and only if this stack contains no items; false otherwise.

    	return (stack.size() == 0);
    
public booleanisEmpty()
Tests if this stack is empty.

return
true if and only if this stack contains no items; false otherwise.

    	return (stack.size() == 0);
    
public java.lang.Objectpeek()
Looks at the object at the top of this stack without removing it from the stack.

return
the object at the top of this stack (the last item of the Vector object).
exception
java.util.EmptyStackException if the stack is empty.

    	if (stack.size() == 0)
    		throw new java.util.EmptyStackException();
    	return stack.get(stack.size()-1);
    
public java.lang.Objectpop()
Pops the object that is at the top of this stack.

return
The object at the top of the stack
exception
java.util.EmptyStackException if the stack is empty.

    	if (stack.size() == 0)
    		throw new java.util.EmptyStackException();
    	return stack.remove(stack.size()-1);
    
public voidpush(java.lang.Object object)
Pushes the object at the top of this stack.

param
object the item to be pushed into the stack.

    	stack.add(object);
    
public intsize()
Gets the current size of the stack.

return
The number of entries in the stack.

    	return stack.size();