// shuffleDisks - shuffle input disks slice depending on the
// erasure distribution. Return shuffled slice of disks with
// their expected distribution.
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
}
564910
func Shuffle(from FixedDataGrid) FixedDataGrid {
	_, rows := from.Size()
	if inst, ok := from.(*DenseInstances); ok {
		for i := 0; i < rows; i++ {
			j := rand.Intn(i + 1)
			inst.swapRows(i, j)
		}
		return inst
	} else {
		return LazyShuffle(from)
	}
}
1179376
func RandomBytes(count int) []byte {
	b := make([]byte, count)
	crand.Read(b)
	return b
}
520727
func shuffle(input []string) []string {
	tmp := make([]string, len(input))
	r := rand.New(rand.NewSource(time.Now().Unix()))
	for i, j := range r.Perm(len(input)) {
		tmp[i] = input[j]
	}
	return tmp
}
1298125
func Slice(slice interface{}) {
	rv := reflect.ValueOf(slice)
	swap := reflect.Swapper(slice)
	rand.Shuffle(rv.Len(), swap)
}
926377
func checkCacheDiskConsistency(formats []*formatCacheV1) error {
	var disks = make([]string, len(formats))
	// Collect currently available disk uuids.
	for index, format := range formats {
		if format == nil {
			disks[index] = ""
			continue
		}
		disks[index] = format.Cache.This
	}
	for i, format := range formats {
		if format == nil {
			continue
		}
		j := findCacheDiskIndex(disks[i], format.Cache.Disks)
		if j == -1 {
			return fmt.Errorf("UUID on positions %d:%d do not match with , expected %s", i, j, disks[i])
		}
		if i != j {
			return fmt.Errorf("UUID on positions %d:%d do not match with , expected %s got %s", i, j, disks[i], format.Cache.Disks[j])
		}
	}
	return nil
}
1206770
func (neq Neq) sortedKeys() []string {
	keys := make([]string, 0, len(neq))
	for key := range neq {
		keys = append(keys, key)
	}
	sort.Strings(keys)
	return keys
}
752240
func shuffle(m []string) {
	for _ = range m {
		i := rand.Intn(len(m))
		j := rand.Intn(len(m))
		m[i], m[j] = m[j], m[i]
	}
}
1087131
func (g *Cloud) DeleteDisk(diskToDelete string) error {
	err := g.doDeleteDisk(diskToDelete)
	if isGCEError(err, "resourceInUseByAnotherResource") {
		return volerr.NewDeletedVolumeInUseError(err.Error())
	}

	if err == cloudprovider.DiskNotFound {
		return nil
	}
	return err
}
1157817
func Shuffle(ref interface{}) {
	switch ref.(type) {
	case []bool:
		ary := ref.([]bool)
		t := Shuffler(ary).(reflect.Value)
		for i := 0; i < t.Len(); i++ {
			ary[i] = bool(t.Index(i).Bool())
		}
	case []float32:
		ary := ref.([]float32)
		t := Shuffler(ary).(reflect.Value)
		for i := 0; i < t.Len(); i++ {
			ary[i] = float32(t.Index(i).Float())
		}
	case []float64:
		ary := ref.([]float64)
		t := Shuffler(ary).(reflect.Value)
		for i := 0; i < t.Len(); i++ {
			ary[i] = float64(t.Index(i).Float())
		}
	case []int:
		ary := ref.([]int)
		t := Shuffler(ary).(reflect.Value)
		for i := 0; i < t.Len(); i++ {
			ary[i] = int(t.Index(i).Int())
		}
	case []int8:
		ary := ref.([]int8)
		t := Shuffler(ary).(reflect.Value)
		for i := 0; i < t.Len(); i++ {
			ary[i] = int8(t.Index(i).Int())
		}
	case []int16:
		ary := ref.([]int16)
		t := Shuffler(ary).(reflect.Value)
		for i := 0; i < t.Len(); i++ {
			ary[i] = int16(t.Index(i).Int())
		}
	case []int32:
		ary := ref.([]int32)
		t := Shuffler(ary).(reflect.Value)
		for i := 0; i < t.Len(); i++ {
			ary[i] = int32(t.Index(i).Int())
		}
	case []int64:
		ary := ref.([]int64)
		t := Shuffler(ary).(reflect.Value)
		for i := 0; i < t.Len(); i++ {
			ary[i] = int64(t.Index(i).Int())
		}
	case []uint:
		ary := ref.([]uint)
		t := Shuffler(ary).(reflect.Value)
		for i := 0; i < t.Len(); i++ {
			ary[i] = uint(t.Index(i).Uint())
		}
	case []uint8:
		ary := ref.([]uint8)
		t := Shuffler(ary).(reflect.Value)
		for i := 0; i < t.Len(); i++ {
			ary[i] = uint8(t.Index(i).Uint())
		}
	case []uint16:
		ary := ref.([]uint16)
		t := Shuffler(ary).(reflect.Value)
		for i := 0; i < t.Len(); i++ {
			ary[i] = uint16(t.Index(i).Uint())
		}
	case []uint32:
		ary := ref.([]uint32)
		t := Shuffler(ary).(reflect.Value)
		for i := 0; i < t.Len(); i++ {
			ary[i] = uint32(t.Index(i).Uint())
		}
	case []uint64:
		ary := ref.([]uint64)
		t := Shuffler(ary).(reflect.Value)
		for i := 0; i < t.Len(); i++ {
			ary[i] = uint64(t.Index(i).Uint())
		}
	case []string:
		ary := ref.([]string)
		t := Shuffler(ary).(reflect.Value)
		for i := 0; i < t.Len(); i++ {
			ary[i] = string(t.Index(i).String())
		}
	}
}
50426
func findCacheDiskIndex(disk string, disks []string) int {
	for index, uuid := range disks {
		if uuid == disk {
			return index
		}
	}
	return -1
}
877993
func (m *MockInstance) UpdateDisks(arg0 manifest.Manifest, arg1 ui.Stage) ([]disk.Disk, error) {
	ret := m.ctrl.Call(m, "UpdateDisks", arg0, arg1)
	ret0, _ := ret[0].([]disk.Disk)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
64487
func (client *Client) ResizeDisk(diskId string, sizeGB int) error {
	args := ResizeDiskArgs{
		DiskId:  diskId,
		NewSize: sizeGB,
	}
	response := ResizeDiskResponse{}
	err := client.Invoke("ResizeDisk", &args, &response)
	return err
}
904853
func shuffle(src rand.Source, in []peer.Identifier) []peer.Identifier {
	shuffled := make([]peer.Identifier, len(in))
	r := rand.New(src)
	copy(shuffled, in)
	for i := len(in) - 1; i > 0; i-- {
		j := r.Intn(i + 1)
		shuffled[i], shuffled[j] = shuffled[j], shuffled[i]
	}
	return shuffled
}
875320
func ShuffleInt64(a []int64) []int64 {
	for i := range a {
		j := rand.Intn(i + 1)
		a[i], a[j] = a[j], a[i]
	}

	return a
}
966175
func sortKeys(vals map[string]counter) (keys []string) {
	for k := range vals {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	return keys
}
453496
func (gce *Connection) CreateDisks(zone string, disks []DiskSpec) ([]*Disk, error) {
	results := make([]*Disk, len(disks))
	for i, disk := range disks {
		d, err := disk.newDetached()
		if err != nil {
			return []*Disk{}, errors.Annotate(err, "cannot create disk spec")
		}
		if err := gce.createDisk(zone, d); err != nil {
			return []*Disk{}, errors.Annotatef(err, "cannot create disk %q", disk.Name)
		}
		results[i] = NewDisk(d)
	}
	return results, nil
}