Having an array of numbers I want to randomly pick every index of it with a random generator. What is the best practise for the random generator to avoid useless loops on indexes that have already selected? So far I use an ArrayList tho store the already selected ones but I feel that in the end this algorithm will have many wasted loops in the end. Here is the code:
Random r = new Random();
ArrayList<Integer> found = new ArrayList<Integer>();
while(notAllPassed){
int prediction = r.nextInt(sizeOfArray);
if(!found.contains(prediction){
found.Add(prediction);
//Do stuff
}
}