find_ge<E> function

E find_ge<E>(
  1. List<E> a,
  2. E x, {
  3. Comparator<E>? compare,
  4. ToKey<E, Object>? key,
})

Find leftmost item greater than or equal to x

Implementation

E find_ge<E>(List<E> a, E x, {Comparator<E>? compare, ToKey<E, Object>? key}) {
  // todo unit-test custom compare and key
  int i = bisect_left(a, x, compare: compare, key: key);
  if (i != a.length) {
    return a[i];
  }
  throw ArgumentError('Value not found');
}