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

@ -64,6 +64,23 @@ func (m *sorted_map[K, V]) Clone() Map[K, V] {
return &sorted_map[K, V]{maps: m.maps.Clone(), keys: getKeys(m.maps)}
}
func (m *sorted_map[K, V]) Iter() <-chan *Entry[K, V] {
c := make(chan *Entry[K, V], m.Count())
go func() {
for _, k := range m.keys {
v, _ := m.maps.Get(k)
c <- &Entry[K, V]{
Key: k,
Value: v,
}
}
close(c)
}()
return c
}
func (m *sorted_map[K, V]) ForEach(f func(K, V)) {
m.maps.ForEach(f)
}