cbrfWorker/utils/array_to_map.go

12 lines
213 B
Go
Raw Normal View History

2023-05-22 19:48:44 +00:00
package utils
func ArrayToMap[T any, V comparable](array []T, key func(T) V) map[V]T {
result := make(map[V]T, len(array))
for _, element := range array {
result[key(element)] = element
}
return result
}