Skip to content

Instantly share code, notes, and snippets.

@hukl
Created March 14, 2017 14:01
Show Gist options
  • Save hukl/d9f83d77d112f5fd397f6bc5a1c0d196 to your computer and use it in GitHub Desktop.
Save hukl/d9f83d77d112f5fd397f6bc5a1c0d196 to your computer and use it in GitHub Desktop.
Minimal Integer Set Implementation in Go
type int_set map[int]struct{}
func (s *int_set) Add(key int) {
(*s)[key] = struct{}{}
}
func (s *int_set) Values() []int {
var result []int
for k, _ := range *s {
result = append(result, k)
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment