map迭代支持终止迭代控制

This commit is contained in:
2023-03-07 17:48:41 +08:00
parent e87648974d
commit e437ba87af
6 changed files with 25 additions and 9 deletions

View File

@ -299,6 +299,9 @@ func (n *normal) Iterator(handleFunc IteratorFunc) {
n.RLock()
defer n.RUnlock()
for key, val := range n.data {
handleFunc(key, val)
if !handleFunc(key, val) {
// 终止迭代
break
}
}
}