FileDocCategorySizeDatePackage
IntStack.javaAPI DocJava SE 6 API2771Tue Jun 10 00:22:50 BST 2008com.sun.org.apache.xerces.internal.util

IntStack

public final class IntStack extends Object
A simple integer based stack. moved to com.sun.org.apache.xerces.internal.util by neilg to support the XPathMatcher.
author
Andy Clark, IBM
version
$Id: IntStack.java,v 1.2.6.1 2005/09/05 09:03:46 neerajbj Exp $

Fields Summary
private int
fDepth
Stack depth.
private int[]
fData
Stack data.
Constructors Summary
Methods Summary
public voidclear()
Clears the stack.

        fDepth = 0;
    
public intelementAt(int depth)
Returns the element at the specified depth in the stack.

        return fData[depth];
    
private voidensureCapacity(int size)
Ensures capacity.

        if (fData == null) {
            fData = new int[32];
        }
        else if (fData.length <= size) {
            int[] newdata = new int[fData.length * 2];
            System.arraycopy(fData, 0, newdata, 0, fData.length);
            fData = newdata;
        }
    
public intpeek()
Peeks at the top of the stack.

        return fData[fDepth - 1];
    
public intpop()
Pops a value off of the stack.

        return fData[--fDepth];
    
public voidprint()
Prints the stack.

        System.out.print('(");
        System.out.print(fDepth);
        System.out.print(") {");
        for (int i = 0; i < fDepth; i++) {
            if (i == 3) {
                System.out.print(" ...");
                break;
            }
            System.out.print(' ");
            System.out.print(fData[i]);
            if (i < fDepth - 1) {
                System.out.print(',");
            }
        }
        System.out.print(" }");
        System.out.println();
    
public voidpush(int value)
Pushes a value onto the stack.

        ensureCapacity(fDepth + 1);
        fData[fDepth++] = value;
    
public intsize()
Returns the size of the stack.

        return fDepth;