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-03-28 17:35:58 +08:00
parent abeabeeb61
commit a5fb792dcf
4 changed files with 158 additions and 12 deletions

View File

@ -1,6 +1,10 @@
package generics
import "sync"
import (
"sync"
"golang.org/x/exp/maps"
)
var _ Map[string, string] = &RWLockMap[string, string]{}
@ -41,10 +45,7 @@ func (m *RWLockMap[K, V]) ForEach(f func(K, V)) {
}
func (m *RWLockMap[K, V]) Clone() Map[K, V] {
new := make(map[K]V, m.Count())
for k, v := range m.m {
new[k] = v
}
new := maps.Clone(m.m)
return &RWLockMap[K, V]{
m: new,