lowerBoundByCompare<K> method

int lowerBoundByCompare<K>(
  1. E element,
  2. K keyOf(
    1. E
    ),
  3. int compare(
    1. K,
    2. K
    ), [
  4. int start = 0,
  5. int? end,
])

Returns the index where element should be in this sorted list.

Uses binary search to find the location of element. This takes on the order of log(n) comparisons. The list must be sorted according to compare of the keyOf of the elements, otherwise the result is unspecified.

If element is in the list, its index is returned, otherwise returns the first position where adding element would keep the list sorted. This may be the length of the list if all elements of the list compare less than element.

If start and end are supplied, only that range is searched, and only that range need to be sorted.

Implementation

int lowerBoundByCompare<K>(
        E element, K Function(E) keyOf, int Function(K, K) compare,
        [int start = 0, int? end]) =>
    algorithms.lowerBoundBy(this, keyOf, compare, element, start, end);