Skip to content

Commit

Permalink
Merge pull request #9374 from Crypt-iQ/fn_set_copy
Browse files Browse the repository at this point in the history
fn: add set copy method Copy
  • Loading branch information
guggero authored Dec 19, 2024
2 parents 8ecef03 + 6fb8269 commit dac4c1f
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 dac4c1f

Please sign in to comment.