ShuffleStrings uses a seeded rand object

This commit is contained in:
Abhishek Shah
2015-09-09 12:08:57 -07:00
parent 891cef4efa
commit da06ecfc1f
3 changed files with 25 additions and 2 deletions

View File

@@ -54,3 +54,11 @@ func Seed(seed int64) {
rng.rand = rand.New(rand.NewSource(seed))
}
// Perm returns, as a slice of n ints, a pseudo-random permutation of the integers [0,n)
// from the default Source.
func Perm(n int) []int {
rng.Lock()
defer rng.Unlock()
return rng.rand.Perm(n)
}