Files
x/container/set/interface.go
2022-03-28 19:39:13 -07:00

29 lines
321 B
Go

package set
var x = struct{}{}
type Set map[any]struct{}
func (s *Set) Init() {
for k := range *s {
delete(*s, k)
}
}
func (s *Set) Add(e any) {
(*s)[e] = x
}
func (s *Set) Remove(e any) {
delete(*s, e)
}
func (s *Set) Contains(e any) bool {
_, c := (*s)[e]
return c
}
func New() *Set {
return new(Set)
}