Package com.android.dx.util
Class LabeledList
java.lang.Object
com.android.dx.util.MutabilityControl
com.android.dx.util.FixedSizeList
com.android.dx.util.LabeledList
- All Implemented Interfaces:
ToHuman
- Direct Known Subclasses:
BasicBlockList
,ByteBlockList
A list of labeled items, allowing easy lookup by label.
-
Constructor Summary
ConstructorDescriptionLabeledList
(int size) LabeledList
(LabeledList old) Constructs a new instance that is a copy of the old instance. -
Method Summary
Modifier and TypeMethodDescriptionfinal int[]
Gets an array containing all of the labels used in this instance, in order.final int
Gets the maximum label (exclusive) of any block added to this instance.final int
indexOfLabel
(int label) Gets the index of the first item in the list with the given label, if any.protected void
set
(int n, LabeledItem item) Sets the element at the given index.void
Shrinks this instance to fit, by removing any unset (null
) elements, leaving the remaining elements in their original order.Methods inherited from class com.android.dx.util.FixedSizeList
equals, get0, getOrNull0, hashCode, set0, size, toHuman, toHuman, toString, toString
Methods inherited from class com.android.dx.util.MutabilityControl
isImmutable, isMutable, setImmutable, throwIfImmutable, throwIfMutable
-
Constructor Details
-
LabeledList
public LabeledList(int size) -
LabeledList
Constructs a new instance that is a copy of the old instance.- Parameters:
old
- instance to copy
-
-
Method Details
-
getMaxLabel
public final int getMaxLabel()Gets the maximum label (exclusive) of any block added to this instance.- Returns:
>= 0;
the maximum label
-
indexOfLabel
public final int indexOfLabel(int label) Gets the index of the first item in the list with the given label, if any.- Parameters:
label
->= 0;
the label to look for- Returns:
>= -1;
the index of the so-labelled item, or-1
if none is found
-
getLabelsInOrder
public final int[] getLabelsInOrder()Gets an array containing all of the labels used in this instance, in order. The returned array is freshly-allocated and so may be modified safely by the caller without impacting this instance.- Returns:
non-null;
ordered array of labels- Throws:
NullPointerException
- thrown if there are anynull
items in this instance
-
shrinkToFit
public void shrinkToFit()Shrinks this instance to fit, by removing any unset (null
) elements, leaving the remaining elements in their original order.- Overrides:
shrinkToFit
in classFixedSizeList
-
set
Sets the element at the given index.- Parameters:
n
->= 0, < size();
which elementitem
-null-ok;
the value to store
-