package gen_data

import (
	"fmt"
	"math/rand"
	ds "source/pkg/data_struct"
)

const (
	MAX_USER_IND = 10000
	PHONE_LEN    = 11
)

func genRandomPhone() string {
	phone := ""
	for i := 0; i < PHONE_LEN; i++ {
		phone += fmt.Sprintf("%d", rand.Intn(10))
	}

	return phone
}

func RecordsShuffled(count int) []ds.MyData {
	data := make([]ds.MyData, count)
	number := 0
	for i := 0; i < count; i++ {
		number = rand.Intn(MAX_USER_IND)
		data[i].Name = fmt.Sprintf("User_%05d", number)
		data[i].Phone = genRandomPhone()
	}

	// Перемешиваем (Fisher-Yates shuffle)
	for i := len(data) - 1; i > 0; i-- {
		j := rand.Intn(i + 1)
		data[i], data[j] = data[j], data[i]
	}

	return data
}

func RecordsSorted(count int) []ds.MyData {
	data := RecordsShuffled(count)

	data = ds.QSort(data, 0, len(data)-1)

	return data
}
