Type alias DirectionFn<T>

DirectionFn<T>: ((element) => number)

A function used to determine the direction a search algorithm should take when traversing data to find a desired element.

Type Parameters

  • T

Type declaration

    • (element): number
    • Parameters

      • element: T

      Returns number

Example

function directionFn(value: number) {
const squared = value ** 2;

return squared - 64;
}

Returns

0 when the desired element has been found. A positive number when the desired element appears after the current element. A negative number when the desired element appears before the current element.