// ShuffleString creates an array of string shuffled values using Fisher–Yates algorithm
16317
func ShuffleString(a []string) []string {
	for i := range a {
		j := rand.Intn(i + 1)
		a[i], a[j] = a[j], a[i]
	}

	return a
}
364214
func RandomString(prefix string, length int) string {
	return RandomRunes(prefix, length, AlphaRunes, NumericRunes)
}
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)
	}
}
1206776
func MergeSortedStrings(n ...[]string) []string {
	var result []string
	if len(n) == 0 {
		return nil
	} else if len(n) == 1 {
		// Special case. Merge single slice with a nil slice, to remove any
		// duplicates from the single slice.
		return MergeSortedStrings(n[0], nil)
	}

	var maxSize int
	for _, a := range n {
		if len(a) > maxSize {
			maxSize = len(a)
		}
	}
	result = make([]string, 0, maxSize) // This will likely be too small but it's a start.

	idxs := make([]int, len(n)) // Indexes we've processed.
	var j int                   // Index we currently think is minimum.

	for {
		j = -1

		// Find the smallest minimum in all slices.
		for i := 0; i < len(n); i++ {
			if idxs[i] >= len(n[i]) {
				continue // We have completely drained all values in this slice.
			} else if j == -1 {
				// We haven't picked the minimum value yet. Pick this one.
				j = i
				continue
			}

			// It this value key is lower than the candidate.

			if n[i][idxs[i]] < n[j][idxs[j]] {
				j = i
			} else if n[i][idxs[i]] == n[j][idxs[j]] {
				// Duplicate value. Throw it away.
				idxs[i]++
			}

		}

		// We could have drained all of the values and be done...
		if j == -1 {
			break
		}

		// First value to just append it and move on.
		if len(result) == 0 {
			result = append(result, n[j][idxs[j]])
			idxs[j]++
			continue
		}

		// Append the minimum value to results if it's not a duplicate of
		// the existing one.

		if result[len(result)-1] < n[j][idxs[j]] {
			result = append(result, n[j][idxs[j]])
		} else if result[len(result)-1] == n[j][idxs[j]] {
			// Duplicate so drop it.
		} else {
			panic("value being merged out of order.")
		}

		idxs[j]++
	}
	return result
}
885889
func randomString(length int) string {
	rand.Seed(time.Now().UnixNano())
	k := make([]rune, length)
	for i := 0; i < length; i++ {
		c := rand.Intn(35)
		if c < 10 {
			c += 48 // numbers (0-9) (0+48 == 48 == '0', 9+48 == 57 == '9')
		} else {
			c += 87 // lower case alphabets (a-z) (10+87 == 97 == 'a', 35+87 == 122 = 'z')
		}
		k[i] = rune(c)
	}
	return string(k)
}
761351
func (vec *T) Shuffle(mask ShuffleMask) *T {
	*vec = vec.Shuffled(mask)
	return vec
}
506743
func (s *Shuffler) Shuffle(data Interface) {
	n := data.Len()
	for i := n - 1; i >= 0; i-- {
		j := (*rand.Rand)(s).Intn(i + 1)
		data.Swap(i, j)
	}
}
15924
func (h *Haikunator) randomString(s []string) string {
	size := len(s)

	if size <= 0 {
		return ""
	}

	return s[h.Random.Intn(size)]
}
274106
func toString(in interface{}) (string, error) {
	inValue := reflect.ValueOf(in)

	switch inValue.Kind() {
	case reflect.String:
		return inValue.String(), nil
	case reflect.Bool:
		b := inValue.Bool()
		if b {
			return "true", nil
		}
		return "false", nil
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		return fmt.Sprintf("%v", inValue.Int()), nil
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
		return fmt.Sprintf("%v", inValue.Uint()), nil
	case reflect.Float32:
		return strconv.FormatFloat(inValue.Float(), byte('f'), -1, 32), nil
	case reflect.Float64:
		return strconv.FormatFloat(inValue.Float(), byte('f'), -1, 64), nil
	}
	return "", fmt.Errorf("No known conversion from " + inValue.Type().String() + " to string")
}
522781
func ToString(v Value) string {
	if s, ok := v.(String); ok {
		return string(s)
	}
	return StringOf(v)
}
1005194
func ShuffleSource(str string, src rand.Source) string {
	if str == "" {
		return str
	}

	runes := []rune(str)
	index := 0
	r := rand.New(src)

	for i := len(runes) - 1; i > 0; i-- {
		index = r.Intn(i + 1)

		if i != index {
			runes[i], runes[index] = runes[index], runes[i]
		}
	}

	return string(runes)
}
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())
		}
	}
}
782035
func ToString(i interface{}) string {
	if i == nil {
		return ""
	}

	if s, ok := i.(string); ok {
		return s
	}

	if sl, ok := i.([]string); ok {
		if len(sl) == 1 {
			return sl[0]
		}
	}

	return ""
}
34134
func (ung UniformGenerator) Shuffle(arr []interface{}) {
	N := len(arr)
	for i := range arr {
		r := int32(i) + ung.Int32n(int32(N-i))
		arr[i], arr[r] = arr[r], arr[i]
	}
}
1308444
func RandString(prefix string, numbytes int) (string, error) {
	buf, err := RandBytes(numbytes)
	if err != nil {
		return "", err
	}
	str := base32.StdEncoding.EncodeToString(buf)
	if prefix != "" {
		str = strings.Join([]string{prefix, str}, "")
	}
	return str, nil
}
240360
func shuffleUp(heap Interface, i int) {
	for {
		pi := (i - 1) / 2 // (i + 1) / 2 - 1, parent
		if i == pi || !heap.Less(pi, i) {
			break
		}
		heap.Swap(pi, i)
		i = pi
	}
}
245141
func ShuffleFloat64(a []float64) []float64 {
	for i := range a {
		j := rand.Intn(i + 1)
		a[i], a[j] = a[j], a[i]
	}

	return a
}