ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
35k stars 2.56k forks source link

Proposal: Add hash sets to the standard library #6919

Open travv0 opened 4 years ago

travv0 commented 4 years ago

Hash sets can be currently be done using AutoHashMap(K, void) but I'd argue that an actual hash set type would make working with them much nicer. Using a hash map, you have to explicitly access the key member of an Entry to get the value (and I sometimes accidentally try value first instead since when used as a set, the keys are the values), pass {} as the value every time you add something, and you have member functions that are meaningless when using it as a set. With a HashSet type you wouldn't have that cruft, and specific operations for working with sets could even be added if desired.

VoilaNeighbor commented 1 year ago

I wonder why this proposal is still awaiting approval. It doesn't seem to incur any harm to the standard library.

lucavenir commented 11 months ago

Personally, I am currently not sure what's the best way to perform quick Set O(n) computations, such as difference, intersection, union, etc. with AutoHashMap alone

teknico commented 6 months ago

Meanwhile, the author of the well-regarded golang-set library is writing ziglang-set.