Sets are just like hashes where the value is always "true" for each key.
Plus you may be able to optimize Set<T> to use less space than Map<T, bool>.
Unrelated, but does anyone know why the new JavaScript set implementation is so limited? Why didn't they bother doing this right?
You can implement most basic functionality easily enough, MDN even has an example [0]. Although I agree that it should really be part of the language.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
With:
{'A': true, 'B': false}
you seem to be suggesting `B` is 'not in the set'. What's `C`?In the true/false implementation, two distinct hash table states (false or key not set) map to one set state (not a member). The program must check whether the key is set, and then check its value.