Generic sets for Go.
For full documentation see pkg.go.dev.
go get github.com/twharmon/sets
package main
import (
"fmt"
"github.com/twharmon/sets"
)
func main() {
// Create a new set of ints
s := sets.New[int]()
// Add some values
s.Add(1, 2, 3)
// Check for a value
s.Contains(2) // true
// Remove a value
s.Remove(2)
// Get slice of all values in set
s.Slice() // [1 3]
// Merge another set into s
s.Merge(sets.New(2, 4))
// Clear the set
s.Clear()
}
Make a pull request.