code: static <E> ImmutableMap<E, Integer> indexMap(Collection<E> list) {
      ImmutableMap.Builder<E, Integer> builder = new ImmutableMap.Builder<>(list.size());
      int i = 0;
      for (E e : list) {
        builder.put(e, i++);
      }
      return builder.build();
    }
docs: Returns a map from the ith element of list to i.