use slices.Reverse from go1.21

This commit is contained in:
Shivaram Lingamneni 2023-08-15 20:45:00 -04:00
parent cc873efd0f
commit b3abd0bf1d
4 changed files with 10 additions and 16 deletions

View file

@ -36,13 +36,6 @@ 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]
}
}
func SliceContains[T comparable](slice []T, elem T) (result bool) {
for _, t := range slice {
if elem == t {