code: public static <T> Collector<T, ?, OptionalLong> minIndex(Comparator<? super T> comparator) {
          class Container {
              T value;
              long count = 0;
              long index = -1;
          }
          return Collector.of(Container::new, (c, t) -> {
              if (c.index == -1 || comparator.compare(c.value, t) > 0) {
                  c.value = t;
                  c.index = c.count;
              }
              c.count++;
          }, (c1, c2) -> {
              if (c1.index == -1 || (c2.index != -1 && comparator.compare(c1.value, c2.value) > 0)) {
                  c2.index += c1.count;
                  c2.count += c1.count;
                  return c2;
              }
              c1.count += c2.count;
              return c1;
          }, c -> c.index == -1 ? OptionalLong.empty() : OptionalLong.of(c.index));
      }
docs: Returns a {@code Collector} which finds the index of the minimal stream
  element according to the specified {@link Comparator}. If there are
  several minimal elements, the index of the first one is returned.
  
  @param <T> the type of the input elements
  @param comparator a {@code Comparator} to compare the elements
  @return a {@code Collector} which finds the index of the minimal element.
  @see #minIndex()
  @since 0.3.5