forked from External/ergo
use slices.Reverse from go1.21
This commit is contained in:
parent
cc873efd0f
commit
b3abd0bf1d
4 changed files with 10 additions and 16 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue