master
nikkiing 2 years ago
parent 2644ccde76
commit 6e37678c34
  1. 10
      pkg/set/set.go

@ -2,6 +2,16 @@ package set
type Set[T comparable] map[T]struct{} type Set[T comparable] map[T]struct{}
func NewSet[T comparable]() Set[T] {
return make(map[T]struct{})
}
func NewSetWithItems[T comparable](items ...T) Set[T] {
s := make(Set[T])
s.AddWithOutEmpty(items...)
return s
}
func (s Set[T]) Add(items ...T) { func (s Set[T]) Add(items ...T) {
for _, v := range items { for _, v := range items {
s[v] = struct{}{} s[v] = struct{}{}

Loading…
Cancel
Save