3 ms·
You should actually be using a `struct{}` as the value, as it takes no space (opposed to a bool). http://play.golang.org/p/KK1ymLzd_e http://play.golang.org/p/
by nickpresta 13y ago
You should actually be using a `struct{}` as the value, as it takes no space (opposed to a bool).
http://play.golang.org/p/KK1ymLzd_e http://play.golang.org/p/KK1ymLzd_e
- dvirsky 13y agoCool, I didn't know that. will change my Set implementation :) BTW You should remember that if you really want a python-like set, map[interface{}]struct{} is not enough - you still have to implement intersection, union, diff yourself. Not that it's rocket science, but I do think this warrants at least a package in the std library, if not a first class type.
- nickpresta 13y agoAgreed. There is an awesome project that provides this: https://github.com/deckarep/golang-set https://github.com/deckarep/golang-set