import { type PrimativeKey, type ReadKeyFunction, type ReadMultipleKeysFunction } from '../key'; import { type IterableOrValue } from '../iterable/iterable'; import { type Maybe } from '../value/maybe.type'; /** * Creates a map by reading keys from the input values. * * Values without a key (null/undefined) are ignored. */ export type KeyValueMapFactory = (values: T[]) => Map; /** * Creates a KeyValueMapFactory that maps values by their key using a ReadKeyFunction. * * @param read - Function that extracts a key from each value * @returns A factory that creates Maps from arrays of values */ export declare function keyValueMapFactory(read: ReadKeyFunction): KeyValueMapFactory; /** * Reads keys off the input values and places them in a Map using a ReadKeyFunction. * * @param values - The array of values to map * @param read - Function that extracts a key from each value * @returns A Map keyed by the extracted keys */ export declare function readKeysToMap(values: T[], read: ReadKeyFunction): Map; /** * Creates a KeyValueMapFactory that maps values by multiple keys using a ReadMultipleKeysFunction. * Each value can appear under multiple keys. * * @param read - Function that extracts multiple keys from each value * @returns A factory that creates Maps from arrays of values */ export declare function multiKeyValueMapFactory(read: ReadMultipleKeysFunction): KeyValueMapFactory; /** * Reads multiple keys off the input values and places them in a Map using a ReadMultipleKeysFunction. * * @param values - The array of values to map * @param read - Function that extracts multiple keys from each value * @returns A Map keyed by the extracted keys */ export declare function readMultipleKeysToMap(values: T[], read: ReadMultipleKeysFunction): Map; /** * Map with an array of values for a key. */ export type MultiValueMap = Map, T[]>; /** * Interface for adding key/value pairs to a map that contains an array of values. */ export interface MultiValueMapBuilder { map(): MultiValueMap; entries(): [Maybe, T[]][]; tuples(): [Maybe, T][]; /** * Deletes all values from the map with the input key. * * Returns true if a value was deleted. * * @param key */ delete(key: Maybe): boolean; /** * Adds the input key/value pair to the map. Use for inserting all Tuple values. * * @param key * @param value */ addTuples(key: Maybe, value: IterableOrValue): void; /** * Adds the input key/value(s) pair to the map. * * Use the addTuple() function if adding a single tuple value to the array. * * @param key * @param value */ add(key: Maybe, value: IterableOrValue): void; /** * Adds all input values with all the input key pairs to the map. Use for inserting multiple Tuple values. * * @param keys * @param value */ addTuplesToKeys(keys: Maybe>, value: IterableOrValue): void; /** * Adds the input keys and value pairs to the map. * * Use the addTuple() function if adding a single tuple value to the array. * * @param keys * @param value */ addToKeys(keys: Maybe>, value: IterableOrValue): void; /** * Returns true if the map contains the input key. * * @param key */ has(key: Maybe): boolean; /** * Returns all current values for the input key. If no values are found, * * @param key */ get(key: Maybe): T[]; } /** * Creates a new MultiValueMapBuilder for building Maps where each key maps to an array of values. * * @returns A new MultiValueMapBuilder instance */ export declare function multiValueMapBuilder(): MultiValueMapBuilder; /** * Determines if two maps have the same keys. * * @param a - The first map * @param b - The second map * @returns true if the maps have the same keys, false otherwise */ export declare function mapsHaveSameKeys(a: Map, b: Map): boolean;