+11
set.go
+11
set.go
···
33
33
maps.Copy(result, other)
34
34
return result
35
35
}
36
+
37
+
// Intersection returns a new set containing elements common to s and other.
38
+
func (s Set[T]) Intersection(other Set[T]) Set[T] {
39
+
result := New[T]()
40
+
for k := range s {
41
+
if _, ok := other[k]; ok {
42
+
result.Add(k)
43
+
}
44
+
}
45
+
return result
46
+
}