com.android.dx.util
Class LabeledList

java.lang.Object
  extended by com.android.dx.util.MutabilityControl
      extended by com.android.dx.util.FixedSizeList
          extended by com.android.dx.util.LabeledList
All Implemented Interfaces:
ToHuman
Direct Known Subclasses:
BasicBlockList, ByteBlockList

public class LabeledList
extends FixedSizeList

A list of labeled items, allowing easy lookup by label.


Constructor Summary
LabeledList(int size)
           
LabeledList(LabeledList old)
          Constructs a new instance that is a copy of the old instance.
 
Method Summary
 int[] getLabelsInOrder()
          Gets an array containing all of the labels used in this instance, in order.
 int getMaxLabel()
          Gets the maximum label (exclusive) of any block added to this instance.
 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 shrinkToFit()
          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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LabeledList

public LabeledList(int size)

LabeledList

public LabeledList(LabeledList old)
Constructs a new instance that is a copy of the old instance.

Parameters:
old - instance to copy
Method Detail

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 any null items in this instance

shrinkToFit

public void shrinkToFit()
Description copied from class: FixedSizeList
Shrinks this instance to fit, by removing any unset (null) elements, leaving the remaining elements in their original order.

Overrides:
shrinkToFit in class FixedSizeList

set

protected void set(int n,
                   LabeledItem item)
Sets the element at the given index.

Parameters:
n - >= 0, < size(); which element
item - null-ok; the value to store


Copyright © 2015. All rights reserved.