Skip to content

Commit

Permalink
Merge branch 'main' into chore/update-codeowners
Browse files Browse the repository at this point in the history
  • Loading branch information
kvaps committed Aug 19, 2024
2 parents 992728a + 28b0def commit 23527f7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pkg/set/set.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package set

type Set[E comparable] map[E]struct{}

func New[E comparable](vals ...E) Set[E] {
s := Set[E]{}
for _, v := range vals {
s[v] = struct{}{}
}
return s
}

func (s Set[E]) Add(vals ...E) {
for _, v := range vals {
s[v] = struct{}{}
}
}

func (s Set[E]) Equals(other Set[E]) bool {
if len(s) != len(other) {
return false
}
for k := range s {
if _, has := other[k]; !has {
return false
}
}
return true
}

0 comments on commit 23527f7

Please sign in to comment.