mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-22 21:54:59 -07:00
Improve rand.shuffle further by splitting into 64-bit and 32-bit parts
This commit is contained in:
@@ -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]
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user