/** * Behaves like a regular JavaScript `Map`, but its iteration order is dependant * on the `compare` function supplied in the constructor. * * Note: The item's sort position is only computed automatically on insertion. * If you update one of the values that the `compare` function depends on, you * must call the `update(key)` method afterwards to ensure the map stays sorted. */ export default class SortedMap implements Map { #private; constructor(compare: Cmp, entries?: readonly (readonly [K, V])[] | null); clear: () => void; get: (key: K) => V | undefined; has: (key: K) => boolean; set(key: K, value: V): this; delete(key: K): boolean; /** * Update the sort position of the element at `key` if necessary. * * This method should be called to notify the SortedMap that one of the * parameters that the `compare` function depends on has been updated and * consequently the sort order must be verified/updated. * * @returns `true` if the sort position of the element with `key` had to be * updated, `false` if not. */ update(key: K): boolean; forEach(callback: (value: V, key: K, map: SortedMap) => void): void; map(callback: (value: V, key: K, map: SortedMap) => T): T[]; get size(): number; [Symbol.iterator]: () => IterableIterator<[K, V]>; entries: () => IterableIterator<[K, V]>; keys: () => IterableIterator; values: () => IterableIterator; [Symbol.toStringTag]: string; } declare type Cmp = (valueA: V, valueB: V, keyA: K, keyB: K) => number; export {};