map.apps Bundle APIs 4.20.0
    Preparing search index...
    • Performs binary search on a sorted array.

      Type Parameters

      • T

        The type of items in the array.

      • U = T

        The type of the item.

      Parameters

      • input: T[]

        An array in sorted order (compatible with the order induced by comparator).

      • item: U

        An item to search for. This does not necessarily have to be an instance of T, but it must be supported by the comparator function.

      • comparator: (a: T, b: U) => number

        A comparison function.

      Returns number

      The index of the item in input, if the item was found. Otherwise, a negative index is returned indicating where the item can be inserted to maintain the current order: returnValue == -insertion point - 1. The actual (positive) insertion index can be obtained by calculating -(returnValue + 1).