@d1g1tal/collections
Version:
JavaScript Collections ES Modules
34 lines (32 loc) • 1.39 kB
TypeScript
/** A {@link Map} that can contain multiple, unique, values for the same key. */
declare class SetMultiMap<K, V> extends Map<K, Set<V>> {
/**
* Adds a new element with a specified key and value to the SetMultiMap.
* If an element with the same key already exists, the value will be added to the underlying {@link Set}.
* If the value already exists in the {@link Set}, it will not be added again.
*
* @param {K} key The key to set.
* @param {V} value The value to add to the SetMultiMap
* @returns {SetMultiMap<K, V>} The SetMultiMap with the updated key and value.
*/
set(key: K, value: V): SetMultiMap<K, V>;
/**
* Checks if a specific key has a specific value.
*
* @param {K} key The key to check.
* @param {V} value The value to check.
* @returns {boolean} True if the key has the value, false otherwise.
*/
hasValue(key: K, value: V): boolean;
find(key: K, iterator: (value: V) => boolean): V | undefined;
/**
* Removes a specific value from a specific key.
*
* @param {K} key The key to remove the value from.
* @param {V | undefined} value The value to remove.
* @returns {boolean} True if the value was removed, false otherwise.
*/
deleteValue(key: K, value: V | undefined): boolean;
get [Symbol.toStringTag](): string;
}
export { SetMultiMap };