From ea4110f666b3c3d66998cae4e68e317df646f2fd Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 30 Aug 2022 02:17:15 -0600 Subject: wip better reattach --- lib/containers/set.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/containers') 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 +} -- cgit v1.2.3-54-g00ecf