3 ms·
How would that be useful? If you need a hash set, use a hash set.
by userbinator 12y ago
How would that be useful? If you need a hash set, use a hash set.
- pcwalton 12y agoFor the same reason any generic type is useful: you can use one implementation for multiple purposes (as a hash map implementation doubles as a perfectly good hash set implementation) without having to duplicate code.
- userbinator 12y agoI think that's backwards: a hash set implementation can be used as a hash map simply by storing objects whose comparison is limited to their key fields. A hash map with values that are all the same and never used just seems like a waste.
- pcwalton 12y agoIt's not a waste, because the fact that unit is zero-sized makes it boil away to nothing at runtime.