erigon-pulse/erigon-lib/common/collections.go
2024-01-04 10:44:57 +01:00

16 lines
294 B
Go

package common
func SliceReverse[T any](s []T) {
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
s[i], s[j] = s[j], s[i]
}
}
func SliceMap[T any, U any](s []T, mapFunc func(T) U) []U {
out := make([]U, 0, len(s))
for _, x := range s {
out = append(out, mapFunc(x))
}
return out
}