github.com/primecitizens/pcz/std@v0.2.1/builtin/slice/slice.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 // 4 // Copyright 2021 The Go Authors. All rights reserved. 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file. 7 8 package stdslice 9 10 // Reverse reverses the elements of the slice in place. 11 func Reverse[E any](s []E) { 12 for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { 13 s[i], s[j] = s[j], s[i] 14 } 15 }