Files
go-easy-utils/mapUtil/map_exists.go
jeffery e9cc195c39 Feature/example test (#24)
example docs
2023-04-12 15:09:44 +08:00

18 lines
376 B
Go

package mapUtil
// MapKeyExists 判断map中的key是否存在
func MapKeyExists[T comparable, T2 any](m map[T]T2, key T) bool {
_, exists := m[key]
return exists
}
// MapValueExists 判断map中的value是否存在
func MapValueExists[T comparable, T2 comparable](m map[T2]T, value T) bool {
for _, v := range m {
if v == value {
return true
}
}
return false
}