v0.0.74
This commit is contained in:
parent
72883cf6bd
commit
1990e5d32d
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user