diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-12-11 22:29:05 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-12-20 20:02:11 -0700 |
commit | 0ba5538b7faba51474c7fd4c5512f795e05a787c (patch) | |
tree | c894b556b2686208ad937d3cccae159acf12eceb /lib/containers/set.go | |
parent | 69464c7bb48872c3403e208c492d2b3e1d87812a (diff) |
rebuildnodes: Improve logging
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 +} |