minWith method

KtMapEntry<K, V>? minWith(
  1. Comparator<KtMapEntry<K, V>> comparator
)

Returns the first entry having the smallest value according to the provided comparator or null if there are no entries.

Implementation

KtMapEntry<K, V>? minWith(Comparator<KtMapEntry<K, V>> comparator) {
  final i = iterator();
  if (!i.hasNext()) return null;
  var min = i.next();
  while (i.hasNext()) {
    final e = i.next();
    if (comparator(min, e) > 0) {
      min = e;
    }
  }
  return min;
}