From ad5656a00af63ca9da8e4dc20d75c9f9a3324786 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 23 Jul 2024 15:38:58 +0800 Subject: [PATCH] 1 --- sync.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sync.go b/sync.go index 470d0b0..1cf6e64 100644 --- a/sync.go +++ b/sync.go @@ -57,6 +57,15 @@ func (this *ConcurrentMap[T1, T2]) Range(f func(key T1, value T2) bool) { }) } +func (this *ConcurrentMap[T1, T2]) GetSize() int { + var size int + this.kvHash.Range(func (key, value interface{}) bool { + size += 1 + return true + }) + return size +} + func (this *ConcurrentMap[T1, T2]) Store(key T1, value T2) { this.kvHash.Store(key, value) }