改进并发安全数据结构,完善示例程序

This commit is contained in:
john
2018-09-06 19:16:08 +08:00
parent f71f142912
commit 68a1a59f3a
15 changed files with 80 additions and 28 deletions

View File

@ -24,12 +24,12 @@ func NewStringStringMap(safe...bool) *StringStringMap {
// 给定回调函数对原始内容进行遍历回调函数返回true表示继续遍历否则停止遍历
func (this *StringStringMap) Iterator(f func (k string, v string) bool) {
this.mu.RLock()
defer this.mu.RUnlock()
for k, v := range this.m {
if !f(k, v) {
break
}
}
this.mu.RUnlock()
}
// 哈希表克隆