并发安全map新增Iterator遍历方法

This commit is contained in:
John
2018-02-07 17:55:52 +08:00
parent 3418f3d547
commit 9333beaf26
10 changed files with 89 additions and 0 deletions

View File

@ -22,6 +22,15 @@ func NewStringStringMap() *StringStringMap {
}
}
// 给定回调函数对原始内容进行遍历
func (this *StringStringMap) Iterator(f func (k string, v string)) {
this.mu.RLock()
for k, v := range this.m {
f(k, v)
}
this.mu.RUnlock()
}
// 哈希表克隆
func (this *StringStringMap) Clone() *map[string]string {
m := make(map[string]string)