minWith method

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

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

Implementation

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