File: shuffle.go

package info (click to toggle)
golang-github-shenwei356-util 0.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 228 kB
  • sloc: makefile: 2
file content (11 lines) | stat: -rw-r--r-- 172 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
package randutil

import "math/rand"

// Shuffle shuffles a slice of int
func Shuffle(s []int) {
	for i := range s {
		j := rand.Intn(i + 1)
		s[i], s[j] = s[j], s[i]
	}
}