//#region src/keyedMap.d.ts /** * A Map implementation that uses a custom key function to determine key equality. * Keys with the same computed internal key are considered equal. * * @example * const map = new KeyedMap<{ x: number; y: number }, string, string>( * (key) => `${key.x},${key.y}`, * ); * map.set({ x: 1, y: 2 }, 'point A'); * map.get({ x: 1, y: 2 }); // 'point A' (different object, same computed key) * * @template K - The type of the external key * @template V - The type of the value * @template InternalKey - The type of the internal key used for comparison */ declare class KeyedMap { private map; private getKey; /** * @param getKey - Function to compute an internal key from the external key * @param entries - Optional initial entries to add to the map */ constructor(getKey: (key: K) => InternalKey, entries?: Iterable<[K, V]>); /** The number of entries in the map */ get size(): number; /** Sets a value for the given key. If the key exists, replaces both key and value. */ set(key: K, value: V): this; /** Sets multiple entries at once. */ setMultiple(entries: Iterable<[K, V]>): this; /** Gets the value for the given key, or undefined if not found. */ get(key: K): V | undefined; /** Checks if the map contains the given key. */ has(key: K): boolean; /** Removes the entry for the given key. Returns true if the entry was removed. */ delete(key: K): boolean; /** Removes multiple entries. Returns the number of entries removed. */ deleteMultiple(keys: Iterable): number; /** Removes all entries from the map. */ clear(): void; /** Executes a callback for each entry in the map. */ forEach(callback: (value: V, key: K, map: KeyedMap) => void, thisArg?: unknown): void; /** Finds the first entry matching the predicate. */ find(predicate: (value: V, key: K) => boolean): { key: K; value: V; } | undefined; /** Gets the value for the given key, or throws if not found. */ getOrThrow(key: K): V; /** Gets the value for the given key, or inserts and returns the fallback value. */ getOrInsert(key: K, fallback: () => V): V; /** Returns values that match the predicate. */ toFilteredValues(predicate: (value: V, key: K) => boolean): V[]; /** Returns all values as an array. */ toValues(): V[]; /** Returns all keys as an array. */ toKeys(): K[]; keys(): IterableIterator; values(): IterableIterator; entries(): IterableIterator<[K, V]>; [Symbol.iterator](): IterableIterator<[K, V]>; } /** * A Map that compares keys by value instead of reference. * Uses `getCompositeKey` to generate a stable string key for any value. * * @example * const map = new CompositeKeyMap<{ x: number; y: number }, string>(); * map.set({ x: 1, y: 2 }, 'point A'); * map.get({ x: 1, y: 2 }); // 'point A' (different object, same value) */ declare class CompositeKeyMap extends KeyedMap { constructor(entries?: Iterable<[K, V]>); } //#endregion export { CompositeKeyMap, KeyedMap };