Adds Count method to BeeMap struct

This adds a Count() method to BeeMap struct that returns the number of
items within the safe map.
This commit is contained in:
Faissal Elamraoui 2016-12-28 12:36:39 +01:00
parent 99093693c8
commit d736d0ca87
1 changed files with 7 additions and 0 deletions

View File

@ -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)
}