binarySearch
在排序数组中查找项目。
| Name | Type | Description |
|---|---|---|
array |
Array | 要搜索的排序数组。 |
itemToFind |
* | 要在数组中查找的项目。 |
comparator |
binarySearch~Comparator | 用于比较项目的功能 数组中的元素。 |
Returns:
指数 itemToFind 在数组中,如果它存在。如果 itemToFind 不存在,返回值是负数,即按位补码(〜) 应该插入itemToFind的索引,以便维护 排序的数组顺序。
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
Type Definitions
用于在执行二分查找时比较两个项目的函数。
| Name | Type | Description |
|---|---|---|
a |
* | 数组中的项目。 |
b |
* | 正在搜索的项目。 |
Returns:
如果返回负值 a小于b,如果是正值,a大于b,如果是0,a等于b。
Example:
function compareNumbers(a, b) {
return a - b;
}
Documentation generated by JSDoc 3.5.5 翻译:https://cesium.xin