Commit 9c719166 by feidy

add ValueMap

parent 3e0ef60a
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
* @Author: zhoufei * @Author: zhoufei
* @Date: 2022-05-19 15:41:06 * @Date: 2022-05-19 15:41:06
* @LastEditors: zhoufei * @LastEditors: zhoufei
* @LastEditTime: 2022-06-07 14:18:16 * @LastEditTime: 2022-06-17 11:01:56
* @FilePath: /utils/map_g.go * @FilePath: /sdc/Users/software/Documents/go/utils/map_g.go
* @Description: 泛型map * @Description: 泛型map
* *
* Copyright (c) 2022 by zhoufei, All Rights Reserved. * Copyright (c) 2022 by zhoufei, All Rights Reserved.
...@@ -86,6 +86,16 @@ func (m *Map[K, T]) Values() []T { ...@@ -86,6 +86,16 @@ func (m *Map[K, T]) Values() []T {
return values 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]) { func (m *Map[K, T]) CloneTo(another *Map[K, T]) {
for k := range m.data { for k := range m.data {
another.data[k] = m.data[k] 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