import { type Maybe } from '../value/maybe.type'; import { type MapFunction } from '../value/map'; import { type DecisionFunction } from '../value/decision'; import { type AscendingSortCompareFunction } from '../sort'; /** * Filters the input values by distance while maintaining the original order of elements. * Values that are too close to each other (based on the minDistance parameter) will be filtered out. * * Items whose extracted value is null are excluded from the result. * * If order is irrelevant, use filterValuesByDistanceNoOrder() instead. * * @param input - Candidate items to dedupe along the value axis. * @param minDistance - Inclusive gap that adjacent kept values must satisfy. * @param getValue - Resolver that maps each item to a numeric coordinate; null skips the item. * @returns Subset of `input` preserved in original index order with min-distance enforced. */ export declare function filterValuesByDistance(input: T[], minDistance: number, getValue: (value: T) => Maybe): T[]; /** * Filters the input values by an arbitrary "distance"/difference from each other and returns the values sorted by their determined distance. * * This is useful in cases where many values are too "close" to each other (generally items that share the same time, or within seconds of each other), and * we are only interested in seeing one of those items. * * @param input - Candidate items to dedupe along the value axis. * @param minDistance - Inclusive gap that adjacent kept values must satisfy. * @param getValue - Resolver that maps each item to a numeric coordinate; null skips the item. * @returns Subset of `input` sorted ascending by extracted value with min-distance enforced. */ export declare function filterValuesByDistanceNoOrder(input: T[], minDistance: number, getValue: (value: T) => Maybe): T[]; /** * Strategy used by {@link applyBestFit} and {@link makeBestFit} to pick the best-fit item and transform the rest. */ export interface BestFitConfig { /** * Function that determines which items are candidates for the best fit. */ readonly filter: (value: T) => boolean; /** * AscendingSortCompareFunction to compare two values to determine which is the best fit. */ readonly compare: AscendingSortCompareFunction; /** * Function that transforms non-best-fit items. */ readonly updateNonBestFit: (value: T) => T; } /** * Same as applyBestFit, but returns a new array, rather than modifying the existing array. * * @param input - Source items considered for best-fit selection; not mutated. * @param config - Strategy describing eligibility, comparison, and non-winner transformation. * @returns Fresh array containing the chosen winner alongside transformed runners-up. * * @dbxUtil * @dbxUtilCategory array * @dbxUtilTags array, best-fit, filter, sort, immutable * @dbxUtilRelated apply-best-fit, find-best-index-set-pair * * @__NO_SIDE_EFFECTS__ */ export declare function makeBestFit(input: T[], config: BestFitConfig): T[]; /** * Used for updating an array so that a single element becomes the "best fit" in whatever context is provided. * * For instance, if two items are selected but only one can be selected by design, this function can be used to * pick the best fit, and update the input array. * * @param input - Mutable array whose runners-up should be rewritten in place. * @param config - Strategy describing eligibility, comparison, and non-winner transformation. * @returns Same `input` reference after the runner-up replacements. * * @dbxUtil * @dbxUtilCategory array * @dbxUtilTags array, best-fit, filter, sort, mutable, in-place * @dbxUtilRelated make-best-fit, find-best-index-set-pair */ export declare function applyBestFit(input: T[], config: BestFitConfig): T[]; /** * Filters and maps the input values to an array. * Combines filtering and mapping operations into a single pass over the data. */ export type FilterAndMapFunction = MapFunction, O[]>; /** * Creates a function that filters the input values and maps all matching values to a new value. * This is a higher-order function that combines filtering and mapping operations. * * @param decisionFunction - Predicate used to decide whether each iterated item flows through. * @param mapFunction - Transform applied to every included item. * @returns Reusable filter-then-map operator over any iterable input. * * @dbxUtil * @dbxUtilCategory array * @dbxUtilKind factory * @dbxUtilTags array, filter, map, transform, factory, iterable * @dbxUtilRelated array-decision-function * * @__NO_SIDE_EFFECTS__ */ export declare function filterAndMapFunction(decisionFunction: DecisionFunction, mapFunction: MapFunction): FilterAndMapFunction;