A go library hashset for O(1)
Initialize set and Add element
import (
...
hashset "github.com/1eedaegon/go-hashset"
...
)
s := hashset.New(1, 2, "3")
s.Add("3") // Since "3" already exists in the Set, its size remains 3.
Remove and Distinguish between different types
import (
...
hashset "github.com/1eedaegon/go-hashset"
...
)
s := hashset.New("1", "2", 3)
s.Remove("1")
s.Remove("multiple")
s.Remove("3") // The length of s is 2, because due to the difference in types.
Other case doc: https://pkg.go.dev/github.com/1eedaegon/go-hashset