// Type definitions for HashMap 2.0.3 // Project: https://github.com/flesler/hashmap // Definitions by: RafaƂ Wrzeszcz , Vasya Aksyonov // Definitions: https://github.com/borisyankov/DefinitelyTyped declare class HashMap { /** * Creates an empty hashmap. */ constructor(); /** * Creates a hashmap with the key-value pairs of map. * * @param map */ constructor(map:HashMap); /** * Creates a hashmap with several key-value pairs. * * @param keysAndValues key1, value1, key2, value2... */ constructor(...keysAndValues:(TKey|TValue)[]); /** * Return value from hashmap. * * @param key Key. * @return Value stored under given key. */ get(key:TKey):TValue; /** * Store value in hashmap. * * @param key Key. * @param value Value. * @return Self. */ set(key:TKey, value:TValue):HashMap; /** * Store several key-value pairs. * * @param keysAndValues key1, value1, key2, value2... * @return Self. */ multi(...keysAndValues:(TKey|TValue)[]):HashMap; /** * Copy all key-value pairs from other to this instance. * * @param map Other map. * @return Self. */ copy(map:HashMap):HashMap; /** * Checks if given key exists in hashmap. * * @param key Key. * @return Whether given key exists in hashmap. */ has(key:TKey):boolean; /** * Returns key under which given value is stored. * * @param value Value. * @return Key which is assigned to value stored. */ search(value:TValue):TKey; /** * Removes given key from hashmap. * * @param key Key. * @return Self. */ remove(key:TKey):HashMap; /** * Returns all contained keys. * * @return List of keys. */ keys():TKey[]; /** * Returns all container values. * * @return List of values. */ values():TValue[]; /** * Returns size of hashmap (number of entries). * * @return Number of entries in hashmap. */ count():number; /** * Clears hashmap. * * @return Self. */ clear():HashMap; /** * Creates a new hashmap with all the key-value pairs of the original * * @return New hashmap. */ clone():HashMap; /** * Iterates over hashmap. * * @param callback Function to be invoked for every hashmap entry. * @return Self. */ forEach(callback:(value:TValue, key:TKey) => void):HashMap; } declare module "hashmap" { export = HashMap; }