This commit is contained in:
Mike Schwörer 2023-01-31 11:01:45 +01:00
parent 72883cf6bd
commit 1990e5d32d
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF

View File

@ -7,3 +7,11 @@ func MapKeyArr[T comparable, V any](v map[T]V) []T {
} }
return result 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
}