-
Notifications
You must be signed in to change notification settings - Fork 7
Utils.Function.binarySearch
commons-math-interpolation / Utils / binarySearch
function binarySearch(a, key): number;Defined in: Utils.ts:176
Searches a sorted array for a value, using the binary search algorithm.
This function corresponds to java.util.Arrays.binarySearch().
Unlike the Java function, it throws an exception when it encounters a NaN value,
and it does not distinguish between -0 and +0.
ArrayLike<number>
The array to be searched. It must be sorted in ascending order, otherwise the result is unspecified.
If the array contains multiple elements equal to key, it is unspecified which one is found.
number
The value to be searched for.
number
The index of key, if it is contained in the array.
Otherwise -(insertionPoint + 1).
The insertion point is the index at which key would be inserted into the array:
the index of the first element greater than key, or a.length if all elements
are less than key.
The return value is >= 0 if and only if key is found.
Error
If key or an array element that is compared with it is NaN.