1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-16 10:42:27 +08:00

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
2022-07-20 11:26:54 +02:00
committed by GitHub
parent ecf325a06c
commit 336e454ce7
4 changed files with 83 additions and 0 deletions

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
}