MCPcopy Create free account
hub / github.com/davecheney/pub / Reverse

Function Reverse

internal/algorithms/algorithms.go:36–40  ·  view source on GitHub ↗

Reverse reverses the order of the elements in the slice.

(a []T)

Source from the content-addressed store, hash-verified

34
35// Reverse reverses the order of the elements in the slice.
36func Reverse[T any](a []T) {
37 for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
38 a[i], a[j] = a[j], a[i]
39 }
40}

Callers 2

threadFunction · 0.92
TestReverseFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestReverseFunction · 0.68