Created
March 14, 2017 14:01
-
-
Save hukl/d9f83d77d112f5fd397f6bc5a1c0d196 to your computer and use it in GitHub Desktop.
Minimal Integer Set Implementation in Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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