import type { Comparator } from '../types.js'; export interface LazyKeySortedMapOptions { /** * Defaults to undefined. * Undefined (default comparator) works well for String keys. * For Number keys - use comparators.numericAsc (or desc), * otherwise sorting will be wrong (lexicographic). */ comparator?: Comparator; } /** * Maintains sorted array of keys. * Sorts **data access**, not on insertion. * * @experimental */ export interface LazyKeySortedMap extends Map { } export declare class LazyKeySortedMap { #private; private readonly map; private readonly maybeSortedKeys; private keysAreSorted; constructor(entries?: [K, V][], opt?: LazyKeySortedMapOptions); /** * Convenience way to create KeySortedMap from object. */ static of(obj: Record): LazyKeySortedMap; get size(): number; clear(): void; has(key: K): boolean; get(key: K): V | undefined; /** * Allows to set multiple key-value pairs at once. */ setMany(obj: Record): this; /** * Insert or update. Keeps keys array sorted at all times. * Returns this (Map-like). */ set(key: K, value: V): this; /** * Delete by key. Returns boolean like Map.delete. */ delete(key: K): boolean; /** * Iterables (Map-compatible), all in sorted order. */ keys(): MapIterator; values(): MapIterator; entries(): MapIterator<[K, V]>; [Symbol.iterator](): MapIterator<[K, V]>; readonly [Symbol.toStringTag] = "KeySortedMap"; /** * Zero-allocation callbacks over sorted data (faster than spreading to arrays). */ forEach(cb: (value: V, key: K, map: Map) => void, thisArg?: any): void; firstKeyOrUndefined(): K | undefined; firstKey(): K; lastKeyOrUndefined(): K | undefined; lastKey(): K; firstValueOrUndefined(): V | undefined; firstValue(): V; lastValueOrUndefined(): V | undefined; lastValue(): V; firstEntryOrUndefined(): [K, V] | undefined; firstEntry(): [K, V]; lastEntryOrUndefined(): [K, V] | undefined; lastEntry(): [K, V]; toJSON(): Record; toObject(): Record; private getSortedKeys; private sortKeys; }