diff options
Diffstat (limited to 'lib/containers')
-rw-r--r-- | lib/containers/set.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/containers/set.go b/lib/containers/set.go index 4e40894..8cd700a 100644 --- a/lib/containers/set.go +++ b/lib/containers/set.go @@ -67,3 +67,15 @@ func (o *Set[T]) Delete(v T) { } delete(*o, v) } + +func (small Set[T]) HasIntersection(big Set[T]) bool { + if len(big) < len(small) { + small, big = big, small + } + for v := range small { + if _, ok := big[v]; ok { + return true + } + } + return false +} |