From 7f316d4a7a918d7fdf6bcb28e9a3fec2e3772efe Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Tue, 22 Aug 2023 14:06:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20hash=20=E5=8C=85=E5=A2=9E=E5=8A=A0=20Cl?= =?UTF-8?q?ear=20=E5=87=BD=E6=95=B0=EF=BC=8C=E7=94=A8=E4=BA=8E=E6=B8=85?= =?UTF-8?q?=E7=A9=BA=20map?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/hash/hash.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/utils/hash/hash.go b/utils/hash/hash.go index ab59e01..60ec9bb 100644 --- a/utils/hash/hash.go +++ b/utils/hash/hash.go @@ -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) + } +}