Feature/example test (#24)

example docs
This commit is contained in:
jeffery
2023-04-12 15:09:44 +08:00
committed by GitHub
parent ac72afe256
commit e9cc195c39
39 changed files with 662 additions and 28 deletions

View File

@@ -1,7 +1,13 @@
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](m map[string]T, value T) bool {
func MapValueExists[T comparable, T2 comparable](m map[T2]T, value T) bool {
for _, v := range m {
if v == value {
return true
@@ -9,9 +15,3 @@ func MapValueExists[T comparable](m map[string]T, value T) bool {
}
return false
}
// MapKeyExists 判断map中的key是否存在
func MapKeyExists(m map[string]any, key string) bool {
_, exists := m[key]
return exists
}