import { type AscendingSortCompareFunction } from '../sort'; import { type IndexNumber, type IndexRef, type IndexRangeInput } from '../value/indexed'; import { type Maybe } from '../value/maybe.type'; /** * A set of index numbers corresponding to items in an array. * * This is useful for cases where you need to reference items by their position in the array. */ export type IndexSet = IndexNumber[]; /** * An array of {@link IndexSetPair} values, associating array items with their indices. */ export type IndexSetPairSet = IndexSetPair[]; /** * Pairs an array item with its index position. */ export interface IndexSetPair extends IndexRef { /** * The item at the index, or undefined if no item exists at that position. */ item: Maybe; } /** * Runs a filter on an array and returns an {@link IndexSet} containing the indices of values that match. * * @param input - array to search through * @param filter - predicate function to test each value * @returns an {@link IndexSet} of indices for matching values */ export declare function findToIndexSet(input: T[], filter: (value: T) => boolean): IndexSet; /** * Expands an {@link IndexSet} into an {@link IndexSetPairSet} by pairing each index with the corresponding item from the input array. * * @param input - source array to retrieve items from * @param indexSet - set of indices to expand * @returns an {@link IndexSetPairSet} pairing each index with its corresponding item */ export declare function expandIndexSet(input: T[], indexSet: IndexSet): IndexSetPairSet; /** * Finds the best item in the input array using the compare function, and returns an {@link IndexSetPair} value. * * The comparison follows ascending sort conventions: a negative return value from the compare function * indicates the second argument is "better" than the first. * * @param input - array of items to search through * @param compare - comparison function used to determine the best item * @returns an {@link IndexSetPair} containing the best item and its index */ export declare function findBest(input: T[], compare: (a: T, b: T) => number): IndexSetPair; /** * Finds the best item in the input {@link IndexSetPairSet} using the compare function, and returns it. * * Pairs with null/undefined items are skipped in favor of pairs with defined items. * * @param input - set of index-item pairs to search through * @param compare - ascending sort comparison function used to determine the best item * @returns the {@link IndexSetPair} containing the best item */ export declare function findBestIndexSetPair(input: IndexSetPairSet, compare: AscendingSortCompareFunction): IndexSetPair; /** * A function that slices a pre-configured index range from an input array. * * @param input - array to slice * @returns the sliced portion of the array */ export type SliceIndexRangeFunction = (input: T[]) => T[]; /** * Creates a {@link SliceIndexRangeFunction} that slices the specified index range from any input array. * * @param inputRange - the index range configuration to use for slicing * @returns a function that slices the configured range from an input array */ export declare function sliceIndexRangeFunction(inputRange: IndexRangeInput): SliceIndexRangeFunction;