MCPcopy Create free account
hub / github.com/google/gapid / Reverse

Function Reverse

core/data/slice/slice.go:93–103  ·  view source on GitHub ↗

Reverse swaps the order of elements in the slice so that the first become the last, and so on.

(s interface{})

Source from the content-addressed store, hash-verified

91// Reverse swaps the order of elements in the slice so that the first become the
92// last, and so on.
93func Reverse(s interface{}) {
94 slice := getSlice(s)
95 tmp := reflect.New(slice.Type().Elem()).Elem()
96 for i, c, m := 0, slice.Len(), slice.Len()/2; i < m; i++ {
97 j := c - i - 1
98 a, b := slice.Index(i), slice.Index(j)
99 tmp.Set(a)
100 a.Set(b)
101 b.Set(tmp)
102 }
103}
104
105// Bytes returns a byte-slice from the given unsafe pointer of the given
106// size in bytes.

Callers

nothing calls this directly

Calls 6

getSliceFunction · 0.85
NewMethod · 0.65
TypeMethod · 0.65
LenMethod · 0.65
IndexMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected