v0.0.74
This commit is contained in:
@@ -7,3 +7,11 @@ func MapKeyArr[T comparable, V any](v map[T]V) []T {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func ArrToMap[T comparable, V any](a []V, keyfunc func(V) T) map[T]V {
|
||||
result := make(map[T]V, len(a))
|
||||
for _, v := range a {
|
||||
result[keyfunc(v)] = v
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
Reference in New Issue
Block a user