Java Array Shuffle shuffle(int[] array, Random rnd)

Here you can find the source of shuffle(int[] array, Random rnd)

Description

shuffle

License

Apache License

Declaration

public static int[] shuffle(int[] array, Random rnd) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Random;

public class Main {
    public static int[] shuffle(int[] array, Random rnd) {
        for (int i = array.length - 1; i > 0; i--) {
            int pos = rnd.nextInt(i + 1);
            int t = array[pos];
            array[pos] = array[i];/*from   w ww . j a v a  2 s.c  om*/
            array[i] = t;
        }
        return array;
    }
}

Related

  1. shuffle(int[] array)
  2. shuffle(int[] array)
  3. shuffle(int[] array)
  4. shuffle(int[] array, Random rand)
  5. shuffle(int[] array, Random rand)
  6. shuffle(int[] ary)
  7. shuffle(int[] input)
  8. shuffle(int[] list, Random rnd)
  9. Shuffle(int[] v)