import { type IndexNumber, type IndexRange, type ReadIndexRangeFunction } from '../value/indexed'; import { type Maybe } from '../value/maybe.type'; import { type ArrayFindDecisionFunction } from './array.find'; /** * Creates an IndexRange for the input array, spanning from index 0 to the array's length. * * @param array - The array to create an index range for. * @returns An IndexRange covering the full extent of the array. */ export declare function indexRangeForArray(array: T[]): IndexRange; /** * Finds a value in the array using the provided decision function, then returns the value at the next index. * * @param array - The array to search through, or undefined/null. * @param find - Decision function used to locate the target element. * @param wrapAround - Whether to wrap around to the beginning of the array if the found value is at or near the last index. * @param steps - Number of steps forward from the found index. Defaults to 1. * @returns The value at the next index, or undefined if no match is found or no next value exists. */ export declare function findNext(array: Maybe, find: ArrayFindDecisionFunction, wrapAround?: boolean, steps?: number): Maybe; /** * Returns the next index of an element in the input array based on the input index. * * Indexes less than 0 are considered to not exist. * * When wrapAround is true, indexes that are larger than the entire array will be used to find an index that is that many steps into the array. * For instance, an index of 5 on an array of length 3 will return the index 1. * * @param array - The array to compute the next index within. * @param index - The current index to step from. * @param wrapAround - Whether to wrap around when stepping past the end of the array. * @param steps - Number of steps forward from the current index. * @returns The computed next index, or undefined if the input index is out of bounds. */ export declare function getArrayNextIndex(array: T[], index: number, wrapAround?: boolean, steps?: number): Maybe; /** * Accessor function that returns a value for the given index if any value's range contains that index. */ export type RangedIndexedValuesArrayAccessor = (index: IndexNumber) => Maybe; /** * Factory function that creates a {@link RangedIndexedValuesArrayAccessor} from an array of values. */ export type RangedIndexedValuesArrayAccessorFactory = (values: T[]) => RangedIndexedValuesArrayAccessor; /** * Creates a factory that produces {@link RangedIndexedValuesArrayAccessor} instances. * * Each accessor maps an index to the value whose range contains that index, or undefined if no range matches. * * @param readIndexRange - Function that reads the index range from each value. * @returns A factory that creates ranged accessors from arrays of values. */ export declare function rangedIndexedValuesArrayAccessorFactory(readIndexRange: ReadIndexRangeFunction): RangedIndexedValuesArrayAccessorFactory; /** * Accessor function that returns a value for the given index. Always returns a value by falling back to the nearest neighbor. */ export type IndexedValuesArrayAccessor = (index: IndexNumber) => T; /** * Factory function that creates an {@link IndexedValuesArrayAccessor} from an array of values. */ export type IndexedValuesArrayAccessorFactory = (values: T[]) => IndexedValuesArrayAccessor; /** * Creates a factory that produces {@link IndexedValuesArrayAccessor} instances. * * Each accessor maps an index to the matching value, falling back to the previous value, then the next value. * This guarantees a value is always returned. * * @param readIndexRange - Function that reads the index range from each value. * @returns A factory that creates indexed accessors from arrays of values. * @throws Error if the provided values array is empty. */ export declare function indexedValuesArrayAccessorFactory(readIndexRange: ReadIndexRangeFunction): IndexedValuesArrayAccessorFactory; /** * Contains the match result for a ranged index lookup, including the matched value and its neighbors. */ export interface RangedIndexValuesArrayAccessorInfo { /** * The value from the range immediately before the matched or queried range. */ readonly prev?: Maybe; /** * The value whose range contains the queried index, or undefined if no range matched. */ readonly match?: Maybe; /** * The value from the range immediately after the matched or queried range. */ readonly next?: Maybe; } /** * Accessor function that returns detailed match info (match, previous, and next values) for the given index. */ export type RangedIndexedValuesArrayInfoAccessor = (index: IndexNumber) => RangedIndexValuesArrayAccessorInfo; /** * Factory function that creates a {@link RangedIndexedValuesArrayInfoAccessor} from an array of values. */ export type RangedIndexedValuesArrayInfoAccessorFactory = (values: T[]) => RangedIndexedValuesArrayInfoAccessor; /** * Configuration for {@link rangedIndexedValuesArrayAccessorInfoFactory}. */ export interface RangedIndexedValuesArrayInfoAccessorFactoryConfig { /** * Reads the index range from a value. The IndexRange is treated as exclusive. */ readonly readIndexRange: ReadIndexRangeFunction; } /** * Creates a factory that produces {@link RangedIndexedValuesArrayInfoAccessor} instances. * * Each accessor sorts the values by their index ranges in ascending order, then for a given index * returns the matching value along with its previous and next neighbors. * * @param config - Configuration containing the index range reader function. * @returns A factory that creates ranged info accessors from arrays of values. */ export declare function rangedIndexedValuesArrayAccessorInfoFactory(config: RangedIndexedValuesArrayInfoAccessorFactoryConfig): RangedIndexedValuesArrayInfoAccessorFactory;