FileDocCategorySizeDatePackage
IntStack.javaAPI DocApache Xerces 3.0.13021Fri Sep 14 20:33:56 BST 2007org.apache.xerces.util

IntStack

public final class IntStack extends Object
A simple integer based stack. moved to org.apache.xerces.util by neilg to support the XPathMatcher.
author
Andy Clark, IBM
version
$Id: IntStack.java 447241 2006-09-18 05:12:57Z mrglavas $

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;