public void writeIndexAnnotation(AnnotatedOutput out, ItemType itemType, String intro) {
    throwIfNotPrepared();

    TreeMap<String, OffsettedItem> index = new TreeMap<String, OffsettedItem>();

    for (OffsettedItem item : items) {
      if (item.itemType() == itemType) {
        String label = item.toHuman();
        index.put(label, item);
      }
    }

    if (index.size() == 0) {
      return;
    }

    out.annotate(0, intro);

    for (Map.Entry<String, OffsettedItem> entry : index.entrySet()) {
      String label = entry.getKey();
      OffsettedItem item = entry.getValue();
      out.annotate(0, item.offsetString() + ' ' + label + '\n');
    }
  }
Writes an index of contents of the items in this instance of the given type. If there are none,
this writes nothing. If there are any, then the index is preceded by the given intro string.

@param out {@code non-null;} where to write to
@param itemType {@code non-null;} the item type of interest
@param intro {@code non-null;} the introductory string for non-empty indices
android/android_framework/dex-maker/src/main/java/com/android/dx/dex/file/MixedItemSection.java