Skip to content

Commit

Permalink
fn: add set copy method Copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Crypt-iQ committed Dec 18, 2024
1 parent 8ecef03 commit 6fb8269
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fn/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ func (s Set[T]) ToSlice() []T {
return maps.Keys(s)
}

// Copy copies s and returns the result.
func (s Set[T]) Copy() Set[T] {
copy := make(Set[T])
for e := range s {
copy.Add(e)
}
return copy
}

// SetDiff returns all the items that are in the first set but not in the
// second.
func SetDiff[T comparable](a, b []T) []T {
Expand Down

0 comments on commit 6fb8269

Please sign in to comment.