FileDocCategorySizeDatePackage
StdTypeList.javaAPI DocAndroid 1.5 API13391Wed May 06 22:41:02 BST 2009com.android.dx.rop.type

StdTypeList

public final class StdTypeList extends com.android.dx.util.FixedSizeList implements TypeList
Standard implementation of {@link TypeList}.

Fields Summary
public static final StdTypeList
EMPTY
non-null; no-element instance
public static final StdTypeList
INT
non-null; the list [int]
public static final StdTypeList
LONG
non-null; the list [long]
public static final StdTypeList
FLOAT
non-null; the list [float]
public static final StdTypeList
DOUBLE
non-null; the list [double]
public static final StdTypeList
OBJECT
non-null; the list [Object]
public static final StdTypeList
RETURN_ADDRESS
non-null; the list [ReturnAddress]
public static final StdTypeList
THROWABLE
non-null; the list [Throwable]
public static final StdTypeList
INT_INT
non-null; the list [int, int]
public static final StdTypeList
LONG_LONG
non-null; the list [long, long]
public static final StdTypeList
FLOAT_FLOAT
non-null; the list [float, float]
public static final StdTypeList
DOUBLE_DOUBLE
non-null; the list [double, double]
public static final StdTypeList
OBJECT_OBJECT
non-null; the list [Object, Object]
public static final StdTypeList
INT_OBJECT
non-null; the list [int, Object]
public static final StdTypeList
LONG_OBJECT
non-null; the list [long, Object]
public static final StdTypeList
FLOAT_OBJECT
non-null; the list [float, Object]
public static final StdTypeList
DOUBLE_OBJECT
non-null; the list [double, Object]
public static final StdTypeList
LONG_INT
non-null; the list [long, int]
public static final StdTypeList
INTARR_INT
non-null; the list [int[], int]
public static final StdTypeList
LONGARR_INT
non-null; the list [long[], int]
public static final StdTypeList
FLOATARR_INT
non-null; the list [float[], int]
public static final StdTypeList
DOUBLEARR_INT
non-null; the list [double[], int]
public static final StdTypeList
OBJECTARR_INT
non-null; the list [Object[], int]
public static final StdTypeList
BOOLEANARR_INT
non-null; the list [boolean[], int]
public static final StdTypeList
BYTEARR_INT
non-null; the list [byte[], int]
public static final StdTypeList
CHARARR_INT
non-null; the list [char[], int]
public static final StdTypeList
SHORTARR_INT
non-null; the list [short[], int]
public static final StdTypeList
INT_INTARR_INT
non-null; the list [int, int[], int]
public static final StdTypeList
LONG_LONGARR_INT
non-null; the list [long, long[], int]
public static final StdTypeList
FLOAT_FLOATARR_INT
non-null; the list [float, float[], int]
public static final StdTypeList
DOUBLE_DOUBLEARR_INT
non-null; the list [double, double[], int]
public static final StdTypeList
OBJECT_OBJECTARR_INT
non-null; the list [Object, Object[], int]
public static final StdTypeList
INT_BOOLEANARR_INT
non-null; the list [int, boolean[], int]
public static final StdTypeList
INT_BYTEARR_INT
non-null; the list [int, byte[], int]
public static final StdTypeList
INT_CHARARR_INT
non-null; the list [int, char[], int]
public static final StdTypeList
INT_SHORTARR_INT
non-null; the list [int, short[], int]
Constructors Summary
public StdTypeList(int size)
Constructs an instance. All indices initially contain null.

param
size the size of the list

        super(size);
    
Methods Summary
public static intcompareContents(TypeList list1, TypeList list2)
Compares the contents of the given two instances for ordering. This is a static method so as to work on arbitrary {@link TypeList} instances.

param
list1 non-null; one list to compare
param
list2 non-null; another list to compare
return
the order of the two lists

        int size1 = list1.size();
        int size2 = list2.size();
        int size = Math.min(size1, size2);

        for (int i = 0; i < size; i++) {
            int comparison = list1.getType(i).compareTo(list2.getType(i));
            if (comparison != 0) {
                return comparison;
            }
        }

        if (size1 == size2) {
            return 0;
        } else if (size1 < size2) {
            return -1;
        } else {
            return 1;
        }
    
public static booleanequalContents(TypeList list1, TypeList list2)
Compares the contents of the given two instances for equality. This is a static method so as to work on arbitrary {@link TypeList} instances.

param
list1 non-null; one list to compare
param
list2 non-null; another list to compare
return
whether the two lists contain corresponding equal elements

        int size = list1.size();

        if (list2.size() != size) {
            return false;
        }

        for (int i = 0; i < size; i++) {
            if (! list1.getType(i).equals(list2.getType(i))) {
                return false;
            }
        }

        return true;
    
public Typeget(int n)
Gets the indicated element. It is an error to call this with the index for an element which was never set; if you do that, this will throw NullPointerException.

param
n >= 0, < size(); which element
return
non-null; the indicated element

        return (Type) get0(n);
    
public TypegetType(int n)
{@inheritDoc}

        return get(n);
    
public intgetWordCount()
{@inheritDoc}

        int sz = size();
        int result = 0;

        for (int i = 0; i < sz; i++) {
            result += get(i).getCategory();
        }

        return result;
    
public static inthashContents(TypeList list)
Returns a hashcode of the contents of the given list. This is a static method so as to work on arbitrary {@link TypeList} instances.

param
list non-null; the list to inspect
return
non-null; the hash code

        int size = list.size();
        int hash = 0;

        for (int i = 0; i < size; i++) {
            hash = (hash * 31) + list.getType(i).hashCode();
        }

        return hash;
    
public static com.android.dx.rop.type.StdTypeListmake(Type type)
Makes a single-element instance.

param
type non-null; the element
return
non-null; an appropriately-constructed instance


                        
         
        StdTypeList result = new StdTypeList(1);
        result.set(0, type);
        return result;
    
public static com.android.dx.rop.type.StdTypeListmake(Type type0, Type type1)
Makes a two-element instance.

param
type0 non-null; the first element
param
type1 non-null; the second element
return
non-null; an appropriately-constructed instance

        StdTypeList result = new StdTypeList(2);
        result.set(0, type0);
        result.set(1, type1);
        return result;
    
public static com.android.dx.rop.type.StdTypeListmake(Type type0, Type type1, Type type2)
Makes a three-element instance.

param
type0 non-null; the first element
param
type1 non-null; the second element
param
type2 non-null; the third element
return
non-null; an appropriately-constructed instance

        StdTypeList result = new StdTypeList(3);
        result.set(0, type0);
        result.set(1, type1);
        result.set(2, type2);
        return result;
    
public static com.android.dx.rop.type.StdTypeListmake(Type type0, Type type1, Type type2, Type type3)
Makes a four-element instance.

param
type0 non-null; the first element
param
type1 non-null; the second element
param
type2 non-null; the third element
param
type3 non-null; the fourth element
return
non-null; an appropriately-constructed instance

        StdTypeList result = new StdTypeList(4);
        result.set(0, type0);
        result.set(1, type1);
        result.set(2, type2);
        result.set(3, type3);
        return result;
    
public voidset(int n, Type type)
Sets the type at the given index.

param
n >= 0, < size(); which element
param
type non-null; the type to store

        set0(n, type);
    
public static java.lang.StringtoHuman(TypeList list)
Returns the given list as a comma-separated list of human forms. This is a static method so as to work on arbitrary {@link TypeList} instances.

param
list non-null; the list to convert
return
non-null; the human form

        int size = list.size();

        if (size == 0) {
            return "<empty>";
        }
        
        StringBuffer sb = new StringBuffer(100);

        for (int i = 0; i < size; i++) {
            if (i != 0) {
                sb.append(", ");
            }
            sb.append(list.getType(i).toHuman());
        }

        return sb.toString();
    
public TypeListwithAddedType(Type type)
{@inheritDoc}

        int sz = size();
        StdTypeList result = new StdTypeList(sz + 1);

        for (int i = 0; i < sz; i++) {
            result.set0(i, get0(i));
        }

        result.set(sz, type);
        result.setImmutable();
        return result;
    
public com.android.dx.rop.type.StdTypeListwithFirst(Type type)
Returns a new instance, which is the same as this instance, except that it has an additional type prepended to the original.

param
type non-null; the new first element
return
non-null; an appropriately-constructed instance

        int sz = size();
        StdTypeList result = new StdTypeList(sz + 1);

        result.set0(0, type);
        for (int i = 0; i < sz; i++) {
            result.set0(i + 1, getOrNull0(i));
        }

        return result;