lowerBound Function

Given a sorted array, computes the position at which the specified value should be inserted into the array so that the array remains sorted.

lowerBound<T, U>(value: T, list: U[], compare: OrderedComparator<T, U>): object

Parameter Type Description
value T The value whose position is to be computed.
list U[] An array of U already sorted according to the comparison criterion.
compare OrderedComparator<T, U> The function used to compare the value with elements in list.

Returns - an object with 'index' corresponding to the computed position and 'equal' set to true if an equivalent element already exists at that index.

Defined in

Last Updated: 08 January, 2020