@meframe/core
Version:
Next generation media processing framework based on WebCodecs
33 lines • 1.41 kB
TypeScript
/**
* Binary search utilities for sorted arrays
*/
/**
* Find the first index where the predicate returns true
* Assumes array is sorted such that predicate returns false for all elements before target
* and true for all elements at or after target
*/
export declare function binarySearchFirst<T>(array: T[], predicate: (item: T) => boolean): number;
/**
* Find an item in a sorted array that contains a given value within its range
* @param array - Sorted array of items with ranges
* @param value - Value to search for
* @param getRange - Function to get start and end values from an item
* @returns The item containing the value, or null if not found
*/
export declare function binarySearchRange<T>(array: T[], value: number, getRange: (item: T) => {
start: number;
end: number;
}): T | null;
/**
* Find all items in a sorted array that overlap with a given range
* @param array - Sorted array of items with ranges
* @param startValue - Start of the search range (inclusive)
* @param endValue - End of the search range (exclusive)
* @param getRange - Function to get start and end values from an item
* @returns Array of items that overlap with the search range
*/
export declare function binarySearchOverlapping<T>(array: T[], startValue: number, endValue: number, getRange: (item: T) => {
start: number;
end: number;
}): T[];
//# sourceMappingURL=binary-search.d.ts.map