binarySearchByCompare<K> method

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

Returns the index of element 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 on the keyOf of elements, otherwise the result is unspecified.

Returns -1 if element does not occur in this list.

If start and end are supplied, only the list range from start to end is searched, and only that range needs to be sorted.


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