News for hackers. Stuff that matters.
Re:An efficient way to make hash maps with insertion ordering by mediumdeviation on Thursday July 01, 2021 @06:46PM (#27705821)
Create a wrapper class that takes a stringifying function that converts the key objects into a primitive and use a Map<string, [K, V]> as the backing store. fast-json-stable-stringify can be used as the default stringifier, and if the objects are large or have a natural key a custom stringifier can also be supplied. Since we are using TS we can have our custom class implement Map<K, V>.
Re:An efficient way to make hash maps with insertion ordering by arsome on Thursday July 01, 2021 @09:49PM (#27707065)
That's very similar to the solution I'm using and that I hate - it involves unnecessary generation and storage of strings and is far less ideal than something like the implementation in tstl I linked above where you can simply provide a custom hash function and equality comparison.