diff options
Diffstat (limited to 'lib/containers/set.go')
-rw-r--r-- | lib/containers/set.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/containers/set.go b/lib/containers/set.go index d3f8ca7..67ba7ac 100644 --- a/lib/containers/set.go +++ b/lib/containers/set.go @@ -150,3 +150,16 @@ func (small Set[T]) HasAny(big Set[T]) bool { } return false } + +func (small Set[T]) Intersection(big Set[T]) Set[T] { + if len(big) < len(small) { + small, big = big, small + } + ret := make(Set[T]) + for v := range small { + if _, ok := big[v]; ok { + ret.Insert(v) + } + } + return ret +} |