FileDocCategorySizeDatePackage
StdTypeList.javaAPI DocAndroid 5.1 API13678Thu Mar 12 22:18:30 GMT 2015com.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
{@code non-null;} no-element instance
public static final StdTypeList
INT
{@code non-null;} the list {@code [int]}
public static final StdTypeList
LONG
{@code non-null;} the list {@code [long]}
public static final StdTypeList
FLOAT
{@code non-null;} the list {@code [float]}
public static final StdTypeList
DOUBLE
{@code non-null;} the list {@code [double]}
public static final StdTypeList
OBJECT
{@code non-null;} the list {@code [Object]}
public static final StdTypeList
RETURN_ADDRESS
{@code non-null;} the list {@code [ReturnAddress]}
public static final StdTypeList
THROWABLE
{@code non-null;} the list {@code [Throwable]}
public static final StdTypeList
INT_INT
{@code non-null;} the list {@code [int, int]}
public static final StdTypeList
LONG_LONG
{@code non-null;} the list {@code [long, long]}
public static final StdTypeList
FLOAT_FLOAT
{@code non-null;} the list {@code [float, float]}
public static final StdTypeList
DOUBLE_DOUBLE
{@code non-null;} the list {@code [double, double]}
public static final StdTypeList
OBJECT_OBJECT
{@code non-null;} the list {@code [Object, Object]}
public static final StdTypeList
INT_OBJECT
{@code non-null;} the list {@code [int, Object]}
public static final StdTypeList
LONG_OBJECT
{@code non-null;} the list {@code [long, Object]}
public static final StdTypeList
FLOAT_OBJECT
{@code non-null;} the list {@code [float, Object]}
public static final StdTypeList
DOUBLE_OBJECT
{@code non-null;} the list {@code [double, Object]}
public static final StdTypeList
LONG_INT
{@code non-null;} the list {@code [long, int]}
public static final StdTypeList
INTARR_INT
{@code non-null;} the list {@code [int[], int]}
public static final StdTypeList
LONGARR_INT
{@code non-null;} the list {@code [long[], int]}
public static final StdTypeList
FLOATARR_INT
{@code non-null;} the list {@code [float[], int]}
public static final StdTypeList
DOUBLEARR_INT
{@code non-null;} the list {@code [double[], int]}
public static final StdTypeList
OBJECTARR_INT
{@code non-null;} the list {@code [Object[], int]}
public static final StdTypeList
BOOLEANARR_INT
{@code non-null;} the list {@code [boolean[], int]}
public static final StdTypeList
BYTEARR_INT
{@code non-null;} the list {@code [byte[], int]}
public static final StdTypeList
CHARARR_INT
{@code non-null;} the list {@code [char[], int]}
public static final StdTypeList
SHORTARR_INT
{@code non-null;} the list {@code [short[], int]}
public static final StdTypeList
INT_INTARR_INT
{@code non-null;} the list {@code [int, int[], int]}
public static final StdTypeList
LONG_LONGARR_INT
{@code non-null;} the list {@code [long, long[], int]}
public static final StdTypeList
FLOAT_FLOATARR_INT
{@code non-null;} the list {@code [float, float[], int]}
public static final StdTypeList
DOUBLE_DOUBLEARR_INT
{@code non-null;} the list {@code [double, double[], int]}
public static final StdTypeList
OBJECT_OBJECTARR_INT
{@code non-null;} the list {@code [Object, Object[], int]}
public static final StdTypeList
INT_BOOLEANARR_INT
{@code non-null;} the list {@code [int, boolean[], int]}
public static final StdTypeList
INT_BYTEARR_INT
{@code non-null;} the list {@code [int, byte[], int]}
public static final StdTypeList
INT_CHARARR_INT
{@code non-null;} the list {@code [int, char[], int]}
public static final StdTypeList
INT_SHORTARR_INT
{@code non-null;} the list {@code [int, short[], int]}
Constructors Summary
public StdTypeList(int size)
Constructs an instance. All indices initially contain {@code 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 {@code non-null;} one list to compare
param
list2 {@code 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 {@code non-null;} one list to compare
param
list2 {@code 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 {@code NullPointerException}.

param
n {@code >= 0, < size();} which element
return
{@code 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 {@code non-null;} the list to inspect
return
{@code 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 {@code non-null;} the element
return
{@code 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 {@code non-null;} the first element
param
type1 {@code non-null;} the second element
return
{@code 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 {@code non-null;} the first element
param
type1 {@code non-null;} the second element
param
type2 {@code non-null;} the third element
return
{@code 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 {@code non-null;} the first element
param
type1 {@code non-null;} the second element
param
type2 {@code non-null;} the third element
param
type3 {@code non-null;} the fourth element
return
{@code 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 {@code >= 0, < size();} which element
param
type {@code 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 {@code non-null;} the list to convert
return
{@code 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 {@code non-null;} the new first element
return
{@code 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;