data-validator-js
Version:
Validation Methods for all types of Data
36 lines (35 loc) • 1.16 kB
TypeScript
export interface IDictionary<K extends number | string, V> {
add(key: K, value: V): boolean;
upsert(key: K, value: V): void;
clear(): void;
containsKey(key: K): boolean;
containsValue(value: V): boolean;
count(): number;
getKeys(): K[];
getValues(): V[];
getValue(key: K): V | boolean;
update(key: K, value: V): boolean;
remove(key: K): boolean;
}
export default class Dictionary<K extends number | string, V> implements IDictionary<K, V> {
private keys;
private values;
constructor();
add(key: K, value: V): boolean;
upsert(key: K, value: V): void;
/**
* Update the dictionary if the entry exists, else add it at the right place such that it is in the sorted order based on the key
* @param key Key for the dictionary entry
* @param value Value for the dictionary entry
*/
sortedUpsert(key: K, value: V): void;
clear(): void;
containsKey(key: K): boolean;
containsValue(value: V): boolean;
count(): number;
getValue(key: K): V | boolean;
getKeys(): K[];
getValues(): V[];
remove(key: K): boolean;
update(key: K, value: V): boolean;
}