private static void encodeList(
      DexFile file, AnnotatedOutput out, String label, ArrayList<? extends EncodedMember> list) {
    int size = list.size();
    int lastIndex = 0;

    if (size == 0) {
      return;
    }

    if (out.annotates()) {
      out.annotate(0, "  " + label + ":");
    }

    for (int i = 0; i < size; i++) {
      lastIndex = list.get(i).encode(file, out, lastIndex, i);
    }
  }
Helper for {@link #encodeOutput}, which writes out the given list. It also annotates the items
(if any and if annotations are enabled).

@param file {@code non-null;} file this instance is part of
@param out {@code non-null;} where to write to
@param label {@code non-null;} the label for the purposes of annotation
@param list {@code non-null;} the list in question
android/android_framework/dex-maker/src/main/java/com/android/dx/dex/file/ClassDataItem.java