mirror of
https://gitee.com/johng/gf
synced 2026-07-06 13:42:46 +08:00
并发安全map新增Iterator遍历方法
This commit is contained in:
@ -22,6 +22,15 @@ func NewStringBoolMap() *StringBoolMap {
|
||||
}
|
||||
}
|
||||
|
||||
// 给定回调函数对原始内容进行遍历
|
||||
func (this *StringBoolMap) Iterator(f func (k string, v bool)) {
|
||||
this.mu.RLock()
|
||||
for k, v := range this.m {
|
||||
f(k, v)
|
||||
}
|
||||
this.mu.RUnlock()
|
||||
}
|
||||
|
||||
// 哈希表克隆
|
||||
func (this *StringBoolMap) Clone() *map[string]bool {
|
||||
m := make(map[string]bool)
|
||||
|
||||
Reference in New Issue
Block a user