minBy method

  1. @override
Option<T> minBy(
  1. int f(
    1. T,
    2. T
    )
)

Returns the element that gives the minimum value with respect to the specified comparison function.

Implementation

@override
Option<T> minBy(int Function(T, T) f) {
  T min;
  if (moveNext()) {
    min = current;
  } else {
    return None;
  }
  for (final element in this) {
    if (f(element, min) < 0) {
      min = element;
    }
  }
  return Some(min);
}