Full-featured Go Set type for string elements.
func Example() {
s1 := Make("red", "green", "blue", "yellow")
s2 := MakeFromText("yellow green white")
fmt.Println(s1.Intersection(s2))
// Output: Set{green yellow}
}Some features of the strset.Set type:
Makebuilds a set from zero or more strings (or[]string...).MakeFromTextbuilds a set from a single string with elements separated by whitespace.Stringmethod returns elements in ascending order.- Methods returning new sets: intersection, union, difference, symmetric difference.
- Methods updating receiver in-place for each operation above.
Popmethod to retrieve and delete one unspecified element.- Need an immutable set? Just remove
updaters.gofrom the build. - 100% test coverage.
- Not thread-safe.
Happy hacking!