From d736d0ca87a0e86d05324f4d3f642cec275f140e Mon Sep 17 00:00:00 2001 From: Faissal Elamraoui Date: Wed, 28 Dec 2016 12:36:39 +0100 Subject: [PATCH] Adds Count method to BeeMap struct This adds a Count() method to BeeMap struct that returns the number of items within the safe map. --- utils/safemap.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/utils/safemap.go b/utils/safemap.go index 2e438f2c..a834a55a 100644 --- a/utils/safemap.go +++ b/utils/safemap.go @@ -84,3 +84,10 @@ func (m *BeeMap) Items() map[interface{}]interface{} { } return r } + +// Count returns the number of items within the map. +func (m *BeeMap) Count() int { + m.lock.RLock() + defer m.lock.RUnlock() + return len(m.bm) +}