find_lt<E> function

E find_lt<E>(
  1. List<E> a,
  2. E x, {
  3. Comparator<E>? compare,
})

Find rightmost value less than x

Implementation

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