mirror of
https://github.com/jeremyd/ergo.git
synced 2026-04-30 01:19:59 -07:00
use genericized slice-reversing function
This commit is contained in:
@@ -27,3 +27,10 @@ func CopyMap[K comparable, V any](input map[K]V) (result map[K]V) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// reverse the order of a slice in place
|
||||
func ReverseSlice[T any](results []T) {
|
||||
for i, j := 0, len(results)-1; i < j; i, j = i+1, j-1 {
|
||||
results[i], results[j] = results[j], results[i]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user