/*! * @author electricessence / https://github.com/electricessence/ * Licensing: MIT https://github.com/electricessence/TypeScript.NET-Core/blob/master/LICENSE.md */ import IMap from "../../IMap"; import KeyValuePair from "../../KeyValuePair"; import {ICollection} from "../ICollection"; import {Action} from "../../FunctionTypes"; export {IMap}; /** * JavaScript hashing can only truly be done with strings (and potentially symbols). * This provides a mechanism to enforce hashable */ export interface IHashable { getHashCode():string|number; } export interface ISymbolizable { getSymbol():symbol; } export interface IDictionary extends ICollection> { keys:TKey[]; values:TValue[]; addByKeyValue(key:TKey, value:TValue):boolean; setValue(key:TKey, value:TValue|undefined):boolean; getValue(key:TKey):TValue|undefined; // It's very common in JS to allow for undefined and check against it. getAssuredValue(key:TKey):TValue; tryGetValue(key:TKey,out:Action):boolean; containsKey(key:TKey):boolean; containsValue(value:TValue):boolean; removeByKey(key:TKey):boolean; removeByValue(value:TValue):number; // See ICollection for the rest. } export interface IStringKeyDictionary extends IDictionary { importMap(map:IMap):boolean; } export interface IOrderedDictionary extends IDictionary { indexOfKey(key:TKey):number; getValueByIndex(index:number):TValue; } export default IDictionary;