maputil: IsDisjoint (#43)

Verifies map a and map b have no keys in common.

if it returns true then the maps are disjoint otherwise a join in some form available
This commit is contained in:
donutloop authored and GitHub committed 2022-07-20 17:26:54 +08:00
1 parent ecf325a06c
commit 336e454ce7
4 files changed
+83

No files matched your search

+10
View File
@@ -108,3 +108,13 @@ func Minus[K comparable, V any](mapA, mapB map[K]V) map[K]V {
}
return result
}
// IsDisjoint two map are disjoint if they have no keys in common
func IsDisjoint[K comparable, V any](mapA, mapB map[K]V) bool {
for k := range mapA {
if _, ok := mapB[k]; ok {
return false
}
}
return true
}