summaryrefslogtreecommitdiff
path: root/lib/containers
diff options
context:
space:
mode:
Diffstat (limited to 'lib/containers')
-rw-r--r--lib/containers/set.go17
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)
}
}