deep-equality-data-structures
Version:
Javascript data structures (e.g., Map, Set) that support deep object equality
39 lines (38 loc) • 1.13 kB
TypeScript
import { DeepMap } from './map';
import { Options } from './options';
/**
* A DeepMap implementation that supports O(1) lookups by both keys and values
* NOTE: All key-value pairs must be 1-to-1
*/
export declare class BiDirectionalDeepMap<K, V, TxK = K, TxV = V> extends DeepMap<K, V, TxK, TxV> {
private readonly valueMap;
/**
* @param entries optional list of key-value pairs to initialize the map
* @param options configuration options
*/
constructor(entries?: readonly (readonly [K, V])[] | null, options?: Options<K, V, TxK, TxV>);
/**
* @inheritdoc
*/
set(key: K, val: V): this;
/**
* @inheritdoc
*/
delete(key: K): boolean;
/**
* @inheritdoc
*/
clear(): void;
/**
* @returns true if the given value is present in the key-value map.
*/
hasValue(val: V): boolean;
/**
* @returns the key associated with the specified value
*/
getKeyByValue(val: V): K | undefined;
/**
* @returns true if a value in the map existed and has been removed, else false
*/
deleteByValue(val: V): boolean;
}