Options
All
  • Public
  • Public/Protected
  • All
Menu

Module algorithm

Index

Functions

binarySearch

  • binarySearch(array: number[], value: number): number
  • Searches the sorted number array for an element and returns the index of that element.

    Parameters

    • array: number[]

      The array to search in.

    • value: number

      The value to search.

    Returns number

    The index of the searched element in the sorted array, if one is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is large than the searched value or, if there is no larger element(include the case that the array is empty), the bitwise complement of array's length.

binarySearchBy

  • binarySearchBy<T>(array: T[], value: T, lessThan: (lhs: T, rhs: T)