fix: settings map read and write concurrently

This commit is contained in:
Noah Hsu
2022-11-28 16:53:16 +08:00
parent 61a06992c3
commit 76f37373e0
4 changed files with 31 additions and 15 deletions

View File

@ -347,6 +347,23 @@ func (m *MapOf[K, V]) Values() []V {
return values
}
func (m *MapOf[K, V]) Count() int {
return len(m.dirty)
}
func (m *MapOf[K, V]) Empty() bool {
return m.Count() == 0
}
func (m *MapOf[K, V]) ToMap() map[K]V {
ans := make(map[K]V)
m.Range(func(key K, value V) bool {
ans[key] = value
return true
})
return ans
}
func (m *MapOf[K, V]) Clear() {
m.Range(func(key K, value V) bool {
m.Delete(key)