code: public static Map<String, Long> toMap(List<KeyLongValue> values) {
      return values
        .stream()
        .collect(uniqueIndex(KeyLongValue::getKey, KeyLongValue::getValue, values.size()));
    }
docs: This method does not keep order of list.