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 - Range boundaries to bake into the returned slicer. * @returns Reusable slicer that extracts the configured range from any input array. * * @dbxUtil * @dbxUtilCategory array * @dbxUtilKind factory * @dbxUtilTags array, slice, index, range, factory * @dbxUtilRelated index-range, find-to-index-set * * @__NO_SIDE_EFFECTS__ */ export declare function sliceIndexRangeFunction(inputRange: IndexRangeInput): SliceIndexRangeFunction;