Improve rand.shuffle further by splitting into 64-bit and 32-bit parts

This commit is contained in:
gingerBill
2024-07-16 18:36:31 +01:00
parent ba49950454
commit 0d881e1561
+7 -1
View File
@@ -618,10 +618,16 @@ shuffle :: proc(array: $T/[]$E, gen := context.random_generator) {
return
}
for i := i64(n - 2); i >= 0; i -= 1 {
i := n - 1
for ; i > (1<<31 - 2); i -= 1 {
j := int63_max(i + 1, gen)
array[i], array[j] = array[j], array[i]
}
for ; i > 0; i -= 1 {
j := int31_max(i32(i + 1), gen)
array[i], array[j] = array[j], array[i]
}
}
/*