All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.cesium.binarySearch.kt Maven / Gradle / Ivy

There is a newer version: 1.90.0-10
Show newest version
// Automatically generated - do not modify!

package cesium

/**
 * Finds an item in a sorted array.
 * ```
 * // 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 = binarySearch(numbers, 6, comparator); // 3
 * ```
 * @param [array] The sorted array to search.
 * @param [itemToFind] The item to find in the array.
 * @param [comparator] The function to use to compare the item to
 *   elements in the array.
 * @return 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.
 * @see Online Documentation
 */
@JsName("\$cesium__binarySearch")
external fun binarySearch(
    array: Array,
    itemToFind: Any,
    comparator: binarySearchComparator,
): Int




© 2015 - 2024 Weber Informatics LLC | Privacy Policy