// shufflePool swaps randomly elements in the server pool
555507
func (nc *Conn) shufflePool() {
	if len(nc.srvPool) <= 1 {
		return
	}
	source := rand.NewSource(time.Now().UnixNano())
	r := rand.New(source)
	for i := range nc.srvPool {
		j := r.Intn(i + 1)
		nc.srvPool[i], nc.srvPool[j] = nc.srvPool[j], nc.srvPool[i]
	}
}
242225
func shuffleNodes(nodes []*nodeState) {
	n := len(nodes)
	rand.Shuffle(n, func(i, j int) {
		nodes[i], nodes[j] = nodes[j], nodes[i]
	})
}
131558
func shuffleAnswers(rng *rand.Rand, answers []dns.RR) []dns.RR {
	n := len(answers)
	for i := 0; i < n; i++ {
		r := i + rng.Intn(n-i)
		answers[r], answers[i] = answers[i], answers[r]
	}

	return answers
}
654438
func shuffleMaps(realized, backup, pending string) error {
	realizedPath := bpf.MapPath(realized)
	backupPath := bpf.MapPath(backup)
	pendingPath := bpf.MapPath(pending)

	if err := os.Rename(realizedPath, backupPath); err != nil && !os.IsNotExist(err) {
		return fmt.Errorf("Unable to back up existing ipcache: %s", err)
	}

	if err := os.Rename(pendingPath, realizedPath); err != nil {
		handleMapShuffleFailure(backup, realized)
		return fmt.Errorf("Unable to shift ipcache into new location: %s", err)
	}

	return nil
}
1086688
func (s SortedTrustedCluster) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}
1176181
func Shuffle(collection Swapper) {
	// Fisher-Yates shuffle.
	for i := collection.Len() - 1; i >= 0; i-- {
		collection.Swap(i, Intn(i+1))
	}
}
1202926
func (a *allocator) RequestPool(addressSpace, pool, subPool string, options map[string]string, v6 bool) (string, *net.IPNet, map[string]string, error) {
	req := &api.RequestPoolRequest{AddressSpace: addressSpace, Pool: pool, SubPool: subPool, Options: options, V6: v6}
	res := &api.RequestPoolResponse{}
	if err := a.call("RequestPool", req, res); err != nil {
		return "", nil, nil, err
	}
	retPool, err := types.ParseCIDR(res.Pool)
	return res.PoolID, retPool, res.Data, err
}
257909
func (vec *T) Shuffled(mask ShuffleMask) (result T) {
	result[0] = vec[mask&3]
	result[1] = vec[(mask>>2)&3]
	result[2] = vec[(mask>>4)&3]
	result[3] = vec[(mask>>6)&3]
	return result
}
1200348
func ShuffleInts(a []int) {
	for i := range a {
		j := rand.Intn(i + 1)
		a[i], a[j] = a[j], a[i]
	}
}
278231
func NewPool(opts ...Option) *Pool {
	pool := &Pool{}
	for _, opt := range opts {
		opt(pool)
	}
	return pool
}
865308
func (pq *BlockPriorityQueue) Swap(i, j int) {
	pq.bh[i], pq.bh[j] = pq.bh[j], pq.bh[i]
	pq.bh[i].heapIdx = i
	pq.bh[j].heapIdx = j
}
324357
func (lobby *Lobby) ShuffleAllSlots() error {
	if lobby.GetPlayerNumber() == lobby.RequiredPlayers() {
		return errors.New("Cannot shuffle a full lobby")
	}

	lobby.Lock()
	lobby.GetAllSlots()
	classes := format.GetClasses(lobby.Type)
	swapClass := make(map[string]bool)

	for _, className := range classes {
		swapClass[className] = rand.Intn(2) == 1
	}

	err := db.DB.Delete(&LobbySlot{}, "lobby_id = ?", lobby.ID).Error
	if err != nil {
		return err
	}

	numClasses := len(classes)
	for i := range lobby.Slots {
		slot := &lobby.Slots[i]
		if swapClass[classes[slot.Slot%numClasses]] {
			slot.Slot = (slot.Slot + numClasses) % (2 * numClasses)
		}
		if err = db.DB.Create(&slot).Error; err != nil {
			return err
		}
	}
	lobby.Unlock()

	lobby.OnChange(true)
	return nil
}
187246
func shuffleDisks(disks []StorageAPI, distribution []int) (shuffledDisks []StorageAPI) {
	if distribution == nil {
		return disks
	}
	shuffledDisks = make([]StorageAPI, len(disks))
	// Shuffle disks for expected distribution.
	for index := range disks {
		blockIndex := distribution[index]
		shuffledDisks[blockIndex-1] = disks[index]
	}
	return shuffledDisks
}
761351
func (vec *T) Shuffle(mask ShuffleMask) *T {
	*vec = vec.Shuffled(mask)
	return vec
}
1142857
func newWorkerPool(tasks []*workTask, concurrency int) *workerPool {
	return &workerPool{
		Tasks:       tasks,
		concurrency: concurrency,
		tasksChan:   make(chan *workTask),
	}
}
1210389
func Random() Balancer {
	logger.Debugf("Creating Random balancer")
	return func(peers []fab.Peer) []fab.Peer {
		logger.Debugf("Load balancing %d peers using Random strategy...", len(peers))

		balancedPeers := make([]fab.Peer, len(peers))
		for i, index := range rand.Perm(len(peers)) {
			balancedPeers[i] = peers[index]
		}
		return balancedPeers
	}
}
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
}