Top Description Fields Constructors Methods
org.droidparts.dexmaker.dx.util

public Class LabeledList

extends FixedSizeList
Class Inheritance
Known Direct Subclasses
org.droidparts.dexmaker.dx.rop.code.BasicBlockList
Imports
java.util.Arrays

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

Field Summary

Modifier and TypeField and Description
private final IntList
labelToIndex

Sparse array indexed by label to FixedSizeList index; -1 for an invalid label.

Constructor Summary

AccessConstructor and Description
public
LabeledList(int size)

public
LabeledList(LabeledList
instance to copy
old
)

Constructs a new instance that is a copy of the old instance.

Method Summary

Modifier and TypeMethod and Description
private void
addLabelIndex(int
new label
label
,
int
index of block.
index
)

Adds a label and index to the label-to-index mapping.

public final int[]

Returns:

non-null; ordered array of labels
getLabelsInOrder
()

Gets an array containing all of the labels used in this instance, in order.

public final int

Returns:

>= 0; the maximum label
getMaxLabel
()

Gets the maximum label (exclusive) of any block added to this instance.

public final int

Returns:

>= -1; the index of the so-labelled item, or -1 if none is found
indexOfLabel
(int
>= 0; the label to look for
label
)

Gets the index of the first item in the list with the given label, if any.

private void
rebuildLabelToIndex()

Rebuilds the label-to-index mapping after a shrinkToFit().

private void
removeLabel(int
label to remove
oldLabel
)

Removes a label from the label-to-index mapping.

protected void
set(int
>= 0, < size(); which element
n
,
LabeledItem
null-ok; the value to store
item
)

Sets the element at the given index.

public void
shrinkToFit()

Overrides org.droidparts.dexmaker.dx.util.FixedSizeList.shrinkToFit.

Shrinks this instance to fit, by removing any unset (null) elements, leaving the remaining elements in their original order.
Inherited from org.droidparts.dexmaker.dx.util.FixedSizeList:
equalsget0getOrNull0hashCodeset0sizetoHumantoHumantoStringtoString

Field Detail

labelToIndexback to summary
private final IntList labelToIndex

Sparse array indexed by label to FixedSizeList index; -1 for an invalid label.

Constructor Detail

LabeledListback to summary
public LabeledList(int size)
LabeledListback to summary
public LabeledList(LabeledList old)

Constructs a new instance that is a copy of the old instance.

Parameters
old:LabeledList

instance to copy

Method Detail

addLabelIndexback to summary
private void addLabelIndex(int label, int index)

Adds a label and index to the label-to-index mapping.

Parameters
label:int

new label

index:int

index of block.

getLabelsInOrderback to summary
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:int[]

non-null; ordered array of labels

Exceptions
NullPointerException:
thrown if there are any null items in this instance
getMaxLabelback to summary
public final int getMaxLabel()

Gets the maximum label (exclusive) of any block added to this instance.

Returns:int

>= 0; the maximum label

indexOfLabelback to summary
public final int indexOfLabel(int label)

Gets the index of the first item in the list with the given label, if any.

Parameters
label:int

>= 0; the label to look for

Returns:int

>= -1; the index of the so-labelled item, or -1 if none is found

rebuildLabelToIndexback to summary
private void rebuildLabelToIndex()

Rebuilds the label-to-index mapping after a shrinkToFit().

Note

This assumes that the labels that are in the list are the same, although the indicies may have changed.

removeLabelback to summary
private void removeLabel(int oldLabel)

Removes a label from the label-to-index mapping.

Parameters
oldLabel:int

label to remove

setback to summary
protected void set(int n, LabeledItem item)

Sets the element at the given index.

Parameters
n:int

>= 0, < size(); which element

item:LabeledItem

null-ok; the value to store

shrinkToFitback to summary
public void shrinkToFit()

Overrides org.droidparts.dexmaker.dx.util.FixedSizeList.shrinkToFit.

Doc from org.droidparts.dexmaker.dx.util.FixedSizeList.shrinkToFit.

Shrinks this instance to fit, by removing any unset (null) elements, leaving the remaining elements in their original order.

Annotations
@Override