UNPKG

node-apparatus

Version:

A mix of common components needed for awesome node experience

54 lines (53 loc) 1.88 kB
/** * A sorted map that maintains the order associated with elements. */ export declare class SortedMap<ValueType> { private readonly map; private readonly sortedKeys; /** * The maximum order of the elements in the map. */ private maxOrder; constructor(map?: Map<string, ValueType>, sortedKeys?: Map<string, number>); /** * Set a key-value pair in the map. * @param key The key of the element. * @param value The value of the element. * @param order The order of the element or undefined if you want to maintain insertion order. * @throws If the order is not a valid 32 bit finite number. * @returns The map instance. */ set(key: string, value: ValueType, order?: number | undefined): void; /** * Get the value of a key in the map. * @param key The key of the element. * @returns The value of the element or undefined if the key does not exist. */ get(key: string): ValueType | undefined; /** * Sorts the map based on the order of the elements. * @returns A new map instance with the elements sorted based on the order. * @remarks This method does not modify the original map. * @remarks This method has a time complexity of O(n log n). * @remarks This method has a space complexity of O(n). * @remarks This method is not stable. */ sort(): Map<string, ValueType>; /** * Check if a key exists in the map. * @param key The key of the element. * @returns True if the key exists in the map, false otherwise. */ has(key: string): boolean; /** * Delete a key from the map. * @param key The key of the element. * @returns True if the key was deleted, false otherwise. */ delete(key: string): boolean; /** * Clears the map. */ clear(): void; [Symbol.dispose](): void; }