1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00
This commit is contained in:
2022-05-06 17:29:35 +08:00
parent 25af24d7c0
commit cd0740f443
12 changed files with 102 additions and 6 deletions

View File

@ -34,6 +34,22 @@ func (m *hashMap[K, V]) Exist(key K) bool {
return ok
}
func (m *hashMap[K, V]) Iter() <-chan *Entry[K, V] {
ch := make(chan *Entry[K, V], m.Count())
go func() {
for k, v := range m.m {
ch <- &Entry[K, V]{
Key: k,
Value: v,
}
}
close(ch)
}()
return ch
}
func (m *hashMap[K, V]) ForEach(f func(K, V)) {
for k, v := range m.m {
f(k, v)