private static @NotNull <X> ObjectIntMap<X> indexMap(X @NotNull [] array) {
    ObjectIntMap<X> map = new ObjectIntHashMap<>(array.length);
    for (X x : array) {
      if (!map.containsKey(x)) {
        map.put(x, map.size());
      }
    }
    return map;
  }
private static @NotNull <X> ObjectIntMap<X> indexMap(X @NotNull [] array)