diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-04-05 07:49:02 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-04-05 07:49:02 -0600 |
commit | 68eb7a16b9759646619a7d9dec2b62fa9d0c30cf (patch) | |
tree | 8bb4b70337a299f1dacb3c2858210d4bf6bd4b04 /lib/containers | |
parent | b0f290078d531d2dcb5d34e809b0711ce9b6491e (diff) | |
parent | d7dd6dfd7aeb40f06ff4fbe7f906d8feed64b95f (diff) |
Merge branch 'lukeshu/misc'
Diffstat (limited to 'lib/containers')
-rw-r--r-- | lib/containers/set.go | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/lib/containers/set.go b/lib/containers/set.go index 074d126..af13d50 100644 --- a/lib/containers/set.go +++ b/lib/containers/set.go @@ -138,20 +138,11 @@ func (o Set[T]) TakeOne() T { } func (o Set[T]) Has(v T) bool { - _, has := o[v] - return has + return maps.HasKey(o, v) } -func (small Set[T]) HasAny(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 +func (a Set[T]) HasAny(b Set[T]) bool { + return maps.HaveAnyKeysInCommon(a, b) } func (small Set[T]) Intersection(big Set[T]) Set[T] { @@ -160,7 +151,7 @@ func (small Set[T]) Intersection(big Set[T]) Set[T] { } ret := make(Set[T]) for v := range small { - if _, ok := big[v]; ok { + if maps.HasKey(big, v) { ret.Insert(v) } } |