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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user