feat: hash 包增加 Clear 函数,用于清空 map

This commit is contained in:
kercylan98 2023-08-22 14:06:40 +08:00
parent ab90fa8928
commit 7f316d4a7a
1 changed files with 7 additions and 0 deletions

View File

@ -65,3 +65,10 @@ func RandomGetKeyN[K comparable, V any](m map[K]V, n int) (ks []K) {
}
return
}
// Clear 清空 map
func Clear[K comparable, V any](m map[K]V) {
for k := range m {
delete(m, k)
}
}