// Permute gets the permuted value for n.
187697
func (p *PermutationGenerator) Permute(n int64) int64 {
	// run one step of the LCG
	return (n*p.a + p.c) % p.m
}
489350
func (c Collection) Swap(i, j int) {
	c[i], c[j] = c[j], c[i]
}
1176181
func Shuffle(collection Swapper) {
	// Fisher-Yates shuffle.
	for i := collection.Len() - 1; i >= 0; i-- {
		collection.Swap(i, Intn(i+1))
	}
}
118824
func (s Servers) shuffle() {
	for i := len(s) - 1; i > 0; i-- {
		j := rand.Int31n(int32(i + 1))
		s[i], s[j] = s[j], s[i]
	}
}
843908
func (p PendingEvaluations) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}
1006381
func (iter *PermutationIterator) Next() []interface{} {
	if !iter.HasNext() {
		return nil
	}

	if iter.res[0] != nil {
		for i := iter.r - 1; i > -1; i-- {
			iter.cycles[i] -= 1
			if iter.cycles[i] == 0 {
				for x := i; x < iter.n-1; x++ {
					v := iter.indices[x]
					iter.indices[x] = iter.indices[x+1]
					iter.indices[x+1] = v
				}
				iter.cycles[i] = iter.n - i
			} else {
				x := iter.indices[i]
				iter.indices[i] = iter.indices[iter.n-iter.cycles[i]]
				iter.indices[iter.n-iter.cycles[i]] = x
				break
			}
		}
	}

	for i := 0; i < iter.r; i++ {
		iter.res[i] = iter.pool[iter.indices[i]]
	}

	iter.iters += 1

	return iter.res
}
924967
func (r *Rand) Perm(n int) []int {
	r.Lock()
	perm := r.rand.Perm(n)
	r.Unlock()
	return perm
}
246358
func (iter *PermutationIterator) Reset() {
	iter.iters = 0

	iter.indices = make([]int, iter.n)
	for i := range iter.indices {
		iter.indices[i] = i
	}

	iter.cycles = make([]int, iter.n-(iter.n-iter.r))
	for i := range iter.cycles {
		iter.cycles[i] = iter.n - i
	}

	iter.res = make([]interface{}, iter.r, iter.r)
}
1282846
func (d *state) Reset() {
	// Zero the permutation's state.
	for i := range d.a {
		d.a[i] = 0
	}
	d.state = spongeAbsorbing
	d.buf = d.storage[:0]
}
1075097
func (k *Kites) Shuffle() {
	shuffled := make(Kites, len(*k))
	for i, v := range rand.Perm(len(*k)) {
		shuffled[v] = (*k)[i]
	}

	*k = shuffled
}
744809
func (s UintSlice) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}
754237
func shuffle(src []btcjson.ListUnspentResult) []btcjson.ListUnspentResult {
	dest := make([]btcjson.ListUnspentResult, len(src))
	perm := rand.Perm(len(src))
	for i, v := range perm {
		dest[v] = src[i]
	}
	return dest
}
781295
func (c *Client) Shuffle(shuffle bool) error {
	return c.ShuffleOpt(shuffle, nil)
}
199704
func (b *Sortable) Swap(i, j int) {
	b.Data[i], b.Data[j] = b.Data[j], b.Data[i]
}
1253895
func (l *Locking) Perm(n int) (v []int) {
	l.Lock()
	v = l.R.Perm(n)
	l.Unlock()
	return
}
542957
func (ms *multiSorter) Swap(i, j int) {
	ms.pods[i], ms.pods[j] = ms.pods[j], ms.pods[i]
}
952926
func (cs fileChanges) Swap(i, j int) {
	tmp := cs[i]
	cs[i] = cs[j]
	cs[j] = tmp
}