binarySearch<E> function
Null safety
Returns a position of the value
in sortedList
, if it is there.
If the list isn't sorted according to the compare
function, the result
is unpredictable.
If compare
is omitted, this defaults to calling Comparable.compareTo on
the objects. In this case, the objects must be Comparable.
Returns -1 if value
is not in the list.
Implementation
int binarySearch<E>(List<E> sortedList, E value,
{int Function(E, E)? compare}) {
compare ??= defaultCompare;
return binarySearchBy<E, E>(sortedList, identity, compare, value);
}