1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 08:32:40 +08:00
This commit is contained in:
2022-05-12 09:35:20 +08:00
parent ffaf129ddb
commit 6731e53d7c
6 changed files with 126 additions and 20 deletions

View File

@ -60,6 +60,33 @@ func (m *ConcurrnetMap[K, V]) Iter() <-chan *Entry[K, V] {
return ch
}
func (m *ConcurrnetMap[K, V]) Keys() []K {
keys := make([]K, m.Count())
for _, b := range m.buckets {
keys = append(keys, b.Keys()...)
}
return keys
}
func (m *ConcurrnetMap[K, V]) Values() []V {
values := make([]V, 0, m.Count())
for _, v := range m.buckets {
values = append(values, v.Values()...)
}
return values
}
func (m *ConcurrnetMap[K, V]) ToMap() map[K]V {
mm := make(map[K]V, m.Count())
for _, v := range m.buckets {
mm = Merge(mm, v.ToMap())
}
return mm
}
func (m *ConcurrnetMap[K, V]) ForEach(f func(K, V)) {
var wg sync.WaitGroup