Package com.android.dx.util
Class FixedSizeList
java.lang.Object
com.android.dx.util.MutabilityControl
com.android.dx.util.FixedSizeList
- All Implemented Interfaces:
ToHuman
- Direct Known Subclasses:
AnnotationsList
,BootstrapMethodArgumentsList
,BootstrapMethodsList
,ByteCatchList
,CatchHandlerList
,CatchTable
,CstArray.List
,DalvInsnList
,InnerClassList
,InsnList
,LabeledList
,LineNumberList
,LocalList
,LocalVariableList
,PositionList
,RegisterSpecList
,StdAttributeList
,StdFieldList
,StdMethodList
,StdTypeList
Simple (mostly) fixed-size list of objects, which may be made immutable.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
protected final Object
get0
(int n) Gets the indicated element.protected final Object
getOrNull0
(int n) Gets the indicated element, allowingnull
s to be returned.int
hashCode()
protected final void
Sets the element at the given index, but without doing any type checks on the element.void
Shrinks this instance to fit, by removing any unset (null
) elements, leaving the remaining elements in their original order.final int
size()
Gets the number of elements in this list.toHuman()
Return the "human" string form of this instance.Gets a customized human string for this instance.toString()
Gets a customized string form for this instance.Methods inherited from class com.android.dx.util.MutabilityControl
isImmutable, isMutable, setImmutable, throwIfImmutable, throwIfMutable
-
Constructor Details
-
FixedSizeList
public FixedSizeList(int size) Constructs an instance. All indices initially containnull
.- Parameters:
size
- the size of the list
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
toString
-
toHuman
Return the "human" string form of this instance. This is generally less "debuggy" thantoString()
. This method will only work if every element of the list implementsToHuman
. -
toString
Gets a customized string form for this instance.- Parameters:
prefix
-null-ok;
prefix for the start of the resultseparator
-null-ok;
separator to insert between each itemsuffix
-null-ok;
suffix for the end of the result- Returns:
non-null;
the custom string
-
toHuman
Gets a customized human string for this instance. This method will only work if every element of the list implementsToHuman
.- Parameters:
prefix
-null-ok;
prefix for the start of the resultseparator
-null-ok;
separator to insert between each itemsuffix
-null-ok;
suffix for the end of the result- Returns:
non-null;
the custom string
-
size
public final int size()Gets the number of elements in this list. -
shrinkToFit
public void shrinkToFit()Shrinks this instance to fit, by removing any unset (null
) elements, leaving the remaining elements in their original order. -
get0
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 throwNullPointerException
. This method is protected so that subclasses may offer a safe type-checked public interface to their clients.- Parameters:
n
->= 0, < size();
which element- Returns:
non-null;
the indicated element
-
getOrNull0
Gets the indicated element, allowingnull
s to be returned. This method is protected so that subclasses may (optionally) offer a safe type-checked public interface to their clients.- Parameters:
n
->= 0, < size();
which element- Returns:
null-ok;
the indicated element
-
set0
Sets the element at the given index, but without doing any type checks on the element. This method is protected so that subclasses may offer a safe type-checked public interface to their clients.- Parameters:
n
->= 0, < size();
which elementobj
-null-ok;
the value to store
-