Merge pull request #9374 from Crypt-iQ/fn_set_copy
fn: add set copy method Copy
This commit is contained in:
1 file changed
+9
@@ -95,6 +95,15 @@ func (s Set[T]) ToSlice() []T {
|
|||||||
return maps.Keys(s)
|
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
|
// SetDiff returns all the items that are in the first set but not in the
|
||||||
// second.
|
// second.
|
||||||
func SetDiff[T comparable](a, b []T) []T {
|
func SetDiff[T comparable](a, b []T) []T {
|
||||||
|
|||||||
Reference in new issue
Block a user