android/guava/src/com/google/common/collect/Maps.java
public static <K, V> ImmutableMap<K, V> toMap(
      Iterator<K> keys, Function<? super K, V> valueFunction) {
    checkNotNull(valueFunction);
    // Using LHM instead of a builder so as not to fail on duplicate keys
    Map<K, V> builder = newLinkedHashMap();
    while (keys.hasNext()) {
      K key = keys.next();
      builder.put(key, valueFunction.apply(key));
    }
    return ImmutableMap.copyOf(builder);
  }
public static <K, V> ImmutableMap<K, V> toMap(
      Iterator<K> keys, Function<? super K, V> valueFunction) {
    checkNotNull(valueFunction);
    // Using LHM instead of a builder so as not to fail on duplicate keys
    Map<K, V> builder = newLinkedHashMap();
    while (keys.hasNext()) {
      K key = keys.next();
      builder.put(key, valueFunction.apply(key));
    }
    return ImmutableMap.copyOf(builder);
  }
Returns an immutable map whose keys are the distinct elements of {@code keys} and whose value
for each key was computed by {@code valueFunction}. The map's iteration order is the order of
the first appearance of each key in {@code keys}.

<p>When there are multiple instances of a key in {@code keys}, it is unspecified whether {@code
valueFunction} will be applied to more than one instance of that key and, if it is, which
result will be mapped to that key in the returned map.

@throws NullPointerException if any element of {@code keys} is {@code null}, or if {@code
valueFunction} produces {@code null} for any key
@since 14.0