vendredi 30 juin 2017

Randomly Mixing An Array, But In A Calculated Way

I am trying to figure out a way to "randomly" mix a large array with more than 500,000 integers. I can currently randomly mix the array with:

let offset = Int(randomNumber(uni: pixelCount-1))
array.append(offset)
let pixel = rgba.pixels[index]
let newIndex = rgba.pixels.index(index, offsetBy: (offset-index), limitedBy: pixelCount)

But this is not really what I'm looking for since the mixed array will be different each time I create it. What I am looking for is a way to mix the array, but in a calculated manner that can be repeated so I can reverse the array back to its original state. Can anyone help?




Aucun commentaire:

Enregistrer un commentaire