FileDocCategorySizeDatePackage
IdentityStack.javaAPI DocApache Ant 1.703118Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.util

IdentityStack

public class IdentityStack extends Stack
Identity Stack.
since
Ant 1.7

Fields Summary
Constructors Summary
public IdentityStack()
Default constructor.

    
public IdentityStack(Object o)
Construct a new IdentityStack with the specified Object as the bottom element.

param
o the bottom element.

        super();
        push(o);
    
Methods Summary
public synchronized booleancontains(java.lang.Object o)
Override methods that use .equals() comparisons on elements.

param
o the Object to search for.
return
true if the stack contains the object.
see
java.util.Vector#contains(Object)

        return indexOf(o) >= 0;
    
public static org.apache.tools.ant.util.IdentityStackgetInstance(java.util.Stack s)
Get an IdentityStack containing the contents of the specified Stack.

param
s the Stack to copy; ignored if null.
return
an IdentityStack instance.

        if (s instanceof IdentityStack) {
            return (IdentityStack) s;
        }
        IdentityStack result = new IdentityStack();
        if (s != null) {
            result.addAll(s);
        }
        return result;
    
public synchronized intindexOf(java.lang.Object o, int pos)
Override methods that use .equals() comparisons on elements.

param
o the Object to search for.
param
pos the position from which to search.
return
the position of the object, -1 if not found.
see
java.util.Vector#indexOf(Object, int)

        for (int i = pos; i < size(); i++) {
            if (get(i) == o) {
                return i;
            }
        }
        return -1;
    
public synchronized intlastIndexOf(java.lang.Object o, int pos)
Override methods that use .equals() comparisons on elements.

param
o the Object to search for.
param
pos the position from which to search (backward).
return
the position of the object, -1 if not found.
see
java.util.Vector#indexOf(Object, int)

        for (int i = pos; i >= 0; i--) {
            if (get(i) == o) {
                return i;
            }
        }
        return -1;