Created
August 18, 2020 00:49
-
-
Save calexandrepcjr/ba5c009cd29aaa7c3629de0e43a1be44 to your computer and use it in GitHub Desktop.
Simple Tuple map experiment in TS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Tuple = [unknown, unknown]; | |
export class TupleMap<T> implements Map<Tuple, T> { | |
public [Symbol.iterator](): IterableIterator<[Tuple, T]> { | |
throw new Error("Method not implemented."); | |
} | |
public keys(): IterableIterator<Tuple> { | |
throw new Error("Method not implemented."); | |
} | |
public values(): IterableIterator<T> { | |
throw new Error("Method not implemented."); | |
} | |
public [Symbol.toStringTag]: string; | |
private readonly aMap: Map<string, T> = new Map<string, T>(); | |
public set(aKey: Tuple, aValue: T): this { | |
this.aMap.set(JSON.stringify(aKey), aValue); | |
return this; | |
} | |
public get(aKey: Tuple): T | undefined { | |
return this.aMap.get(JSON.stringify(aKey)); | |
} | |
public clear(): void { | |
return this.aMap.clear(); | |
} | |
public delete(aKey: Tuple): boolean { | |
return this.aMap.delete(JSON.stringify(aKey)); | |
} | |
public forEach( | |
_: (value: T, key: Tuple, map: Map<Tuple, T>) => void, | |
_1?: unknown, | |
): void { | |
throw new Error("Method not implemented"); | |
} | |
public has(aKey: Tuple): boolean { | |
return this.aMap.has(JSON.stringify(aKey)); | |
} | |
public get size(): number { | |
return this.aMap.size; | |
} | |
public entries(): IterableIterator<[Tuple, T]> { | |
throw new Error("Method not implemented"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment