Commit 9c719166 by feidy

add ValueMap

parent 3e0ef60a
......@@ -2,8 +2,8 @@
* @Author: zhoufei
* @Date: 2022-05-19 15:41:06
* @LastEditors: zhoufei
* @LastEditTime: 2022-06-07 14:18:16
* @FilePath: /utils/map_g.go
* @LastEditTime: 2022-06-17 11:01:56
* @FilePath: /sdc/Users/software/Documents/go/utils/map_g.go
* @Description: 泛型map
*
* Copyright (c) 2022 by zhoufei, All Rights Reserved.
......@@ -86,6 +86,16 @@ func (m *Map[K, T]) Values() []T {
return values
}
func (m *Map[K, T]) ValueMap() (rm map[K]T) {
m.lock.Lock()
defer m.lock.Unlock()
rm = make(map[K]T)
for k, v := range m.data {
rm[k] = v.data
}
return
}
func (m *Map[K, T]) CloneTo(another *Map[K, T]) {
for k := range m.data {
another.data[k] = m.data[k]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment