Android ArrayList Random permute(Random random, ArrayList array)

Here you can find the source of permute(Random random, ArrayList array)

Description

permute

Declaration

public static void permute(Random random, ArrayList array) 

Method Source Code

//package com.java2s;
import java.util.ArrayList;
import java.util.Random;

public class Main {
    public static void permute(Random random, ArrayList array) {
        for (int i = 0; i < array.size(); i++) {
            int j = i + random.nextInt(array.size() - i);
            Object tmp = array.get(i);
            array.set(i, array.get(j));//from   w w  w.  jav  a  2  s.co m
            array.set(j, tmp);
        }
    }
}

Related

  1. get_a_random_testData(ArrayList mTestData)