/** * Finds the last item where predicate is true using binary search. * `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[true, ..., true, false, ..., false]`! * * @returns `undefined` if no item matches, otherwise the last item that matches the predicate. */ export declare function findLastMonotonous(array: readonly T[], predicate: (item: T) => boolean): T | undefined; /** * Finds the last item where predicate is true using binary search. * `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[true, ..., true, false, ..., false]`! * * @returns `startIdx - 1` if predicate is false for all items, otherwise the index of the last item that matches the predicate. */ export declare function findLastIdxMonotonous(array: readonly T[], predicate: (item: T) => boolean, startIdx?: number, endIdxEx?: number): number; /** * Finds the first item where predicate is true using binary search. * `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[false, ..., false, true, ..., true]`! * * @returns `undefined` if no item matches, otherwise the first item that matches the predicate. */ export declare function findFirstMonotonous(array: readonly T[], predicate: (item: T) => boolean): T | undefined; /** * Finds the first item where predicate is true using binary search. * `predicate` must be monotonous, i.e. `arr.map(predicate)` must be like `[false, ..., false, true, ..., true]`! * * @returns `endIdxEx` if predicate is false for all items, otherwise the index of the first item that matches the predicate. */ export declare function findFirstIdxMonotonousOrArrLen(array: readonly T[], predicate: (item: T) => boolean, startIdx?: number, endIdxEx?: number): number; /** * Use this when * * You have a sorted array * * You query this array with a monotonous predicate to find the last item that has a certain property. * * You query this array multiple times with monotonous predicates that get weaker and weaker. */ export declare class MonotonousArray { private readonly _array; static assertInvariants: boolean; private _findLastMonotonousLastIdx; private _prevFindLastPredicate; constructor(_array: readonly T[]); /** * The predicate must be monotonous, i.e. `arr.map(predicate)` must be like `[true, ..., true, false, ..., false]`! * For subsequent calls, current predicate must be weaker than (or equal to) the previous predicate, i.e. more entries must be `true`. */ findLastMonotonous(predicate: (item: T) => boolean): T | undefined; }