4 ms·
I'm slightly surprised you found three different set implementations - `map[T]struct{}` is the idiomatic one i see everywhere. I suppose it's not sorted or con
by mappu 7y ago
I'm slightly surprised you found three different set implementations - `map[T]struct{}` is the idiomatic one i see everywhere.
I suppose it's not sorted or concurrent-safe?
- NoodleIncident 7y agoI mean that people make their own per-file or per-package set implementation for their service. There's no point putting it in a common utility package even within the same company, because it's specific to the type of what they're storing. `map[T]struct{}` is only a type, it's not an implementation. You still need a handful of methods, that might be named inconsistently in each implementation by different developers. I will be happy when I never have to think about this again
- masklinn 7y ago> I'm slightly surprised you found three different set implementations - `map[T]struct{}` is the idiomatic one i see everywhere. Set storage is not really the concern here, it's the set-theoretic operations which make sets useful (generally speaking, there are cases where all you need is the set being a set e.g. deduplication). So I wouldn't be surprised that GP found several different implementations of union, intersection, difference, symmetric difference, subset, superset, …