Skip to content

bisectRight

bisectRight<T, V>(items, value, compare): number

Defined in: ordered/bisect-right.ts:16

Finds the rightmost index in items where value could be inserted while keeping items sorted — after any existing element considered equivalent to it.

O(log n) via binary search. items must already be sorted by compare.

T

V = T

readonly T[]

Array sorted ascending by compare.

V

The value to find an insertion point for.

(item, value) => number

Orders an item against value: negative if the item precedes it, positive if the item follows it, 0 if equivalent.

number

The rightmost valid insertion index, in [0, items.length].