Class 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 Details

    • 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 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 any null 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 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