Module: binarySearch

Finds an item in a sorted array.
Parameters:
Name Type Description
array Array The sorted array to search.
itemToFind Object The item to find in the array.
comparator binarySearch~Comparator The function to use to compare the item to elements in the array.
Source:
Returns:
The index of itemToFind in the array, if it exists. If itemToFind does not exist, the return value is a negative number which is the bitwise complement (~) of the index before which the itemToFind should be inserted in order to maintain the sorted order of the array.
Type
Number
Example
// Create a comparator function to search through an array of numbers.
function comparator(a, b) {
    return a - b;
};
var numbers = [0, 2, 4, 6, 8];
var index = Cesium.binarySearch(numbers, 6, comparator); // 3