umontreal.iro.lecuyer.rng
Class RandomPermutation
- java.lang.Object
-
- umontreal.iro.lecuyer.rng.RandomPermutation
-
public class RandomPermutation extends java.lang.ObjectProvides methods to randomly shuffle arrays or lists using a random stream.
-
-
Constructor Summary
Constructors Constructor and Description RandomPermutation()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static voidinit(byte[] array, int n)Initializes array with the first n positive integers in natural order as array[i - 1] = i, for i = 1,..., n.static voidinit(double[] array, int n)Similar toinit(byte[], int).static voidinit(float[] array, int n)Similar toinit(byte[], int).static voidinit(int[] array, int n)Similar toinit(byte[], int).static voidinit(long[] array, int n)Similar toinit(byte[], int).static voidinit(short[] array, int n)Similar toinit(byte[], int).static voidshuffle(boolean[] array, int n, int k, RandomStream stream)Similar toshuffle(Object[], n, k, RandomStream).static voidshuffle(boolean[] array, RandomStream stream)Similar toshuffle(byte[], RandomStream).static voidshuffle(byte[] array, int n, int k, RandomStream stream)Similar toshuffle(Object[], n, k, RandomStream).static voidshuffle(byte[] array, RandomStream stream)Randomly permutes array using stream.static voidshuffle(char[] array, int n, int k, RandomStream stream)Similar toshuffle(Object[], n, k, RandomStream).static voidshuffle(char[] array, RandomStream stream)Similar toshuffle(byte[], RandomStream).static voidshuffle(double[] array, int n, int k, RandomStream stream)Similar toshuffle(Object[], n, k, RandomStream).static voidshuffle(double[] array, RandomStream stream)Similar toshuffle(byte[], RandomStream).static voidshuffle(float[] array, int n, int k, RandomStream stream)Similar toshuffle(Object[], n, k, RandomStream).static voidshuffle(float[] array, RandomStream stream)Similar toshuffle(byte[], RandomStream).static voidshuffle(int[] array, int n, int k, RandomStream stream)Similar toshuffle(Object[], n, k, RandomStream).static voidshuffle(int[] array, RandomStream stream)Similar toshuffle(byte[], RandomStream).static voidshuffle(java.util.List<?> list, int k, RandomStream stream)static voidshuffle(java.util.List<?> list, RandomStream stream)static voidshuffle(long[] array, int n, int k, RandomStream stream)Similar toshuffle(Object[], n, k, RandomStream).static voidshuffle(long[] array, RandomStream stream)Similar toshuffle(byte[], RandomStream).static voidshuffle(java.lang.Object[] array, int n, int k, RandomStream stream)Partially permutes array as follows using stream: draws the new k elements, array[0] to array[k-1], randomly among the old n elements, array[0] to array[n-1], assuming that k <= n <= array.length.static voidshuffle(java.lang.Object[] array, RandomStream stream)Randomly permutes array using stream.static voidshuffle(short[] array, int n, int k, RandomStream stream)Similar toshuffle(Object[], n, k, RandomStream).static voidshuffle(short[] array, RandomStream stream)Similar toshuffle(byte[], RandomStream).
-
-
-
Method Detail
-
init
public static void init(byte[] array, int n)Initializes array with the first n positive integers in natural order as array[i - 1] = i, for i = 1,..., n. The size of array must be at least n.- Parameters:
array- the array to initialize.n- number of elements initialized.
-
init
public static void init(short[] array, int n)Similar toinit(byte[], int).- Parameters:
array- the array to initialize.n- number of elements initialized.
-
init
public static void init(int[] array, int n)Similar toinit(byte[], int).- Parameters:
array- the array to initialize.n- number of elements initialized.
-
init
public static void init(long[] array, int n)Similar toinit(byte[], int).- Parameters:
array- the array to initialize.n- number of elements initialized.
-
init
public static void init(float[] array, int n)Similar toinit(byte[], int).- Parameters:
array- the array to initialize.n- number of elements initialized.
-
init
public static void init(double[] array, int n)Similar toinit(byte[], int).- Parameters:
array- the array to initialize.n- number of elements initialized.
-
shuffle
public static void shuffle(java.util.List<?> list, RandomStream stream)
-
shuffle
public static void shuffle(java.lang.Object[] array, RandomStream stream)Randomly permutes array using stream. This method permutes the whole array.- Parameters:
array- the array being shuffled.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(byte[] array, RandomStream stream)Randomly permutes array using stream. This method permutes the whole array.- Parameters:
array- the array being shuffled.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(short[] array, RandomStream stream)Similar toshuffle(byte[], RandomStream).- Parameters:
array- the array being shuffled.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(int[] array, RandomStream stream)Similar toshuffle(byte[], RandomStream).- Parameters:
array- the array being shuffled.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(long[] array, RandomStream stream)Similar toshuffle(byte[], RandomStream).- Parameters:
array- the array being shuffled.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(char[] array, RandomStream stream)Similar toshuffle(byte[], RandomStream).- Parameters:
array- the array being shuffled.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(boolean[] array, RandomStream stream)Similar toshuffle(byte[], RandomStream).- Parameters:
array- the array being shuffled.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(float[] array, RandomStream stream)Similar toshuffle(byte[], RandomStream).- Parameters:
array- the array being shuffled.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(double[] array, RandomStream stream)Similar toshuffle(byte[], RandomStream).- Parameters:
array- the array being shuffled.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(java.util.List<?> list, int k, RandomStream stream)
-
shuffle
public static void shuffle(java.lang.Object[] array, int n, int k, RandomStream stream)Partially permutes array as follows using stream: draws the new k elements, array[0] to array[k-1], randomly among the old n elements, array[0] to array[n-1], assuming that k <= n <= array.length. In other words, k elements are selected at random without replacement from the first n array elements and are placed in the first k positions, in random order.- Parameters:
array- the array being shuffled.n- selection amongst the first n elements.k- number of elements selected.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(byte[] array, int n, int k, RandomStream stream)Similar toshuffle(Object[], n, k, RandomStream).- Parameters:
array- the array being shuffled.n- selection amongst the first n elements.k- number of elements selected.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(short[] array, int n, int k, RandomStream stream)Similar toshuffle(Object[], n, k, RandomStream).- Parameters:
array- the array being shuffled.n- selection amongst the first n elements.k- number of elements selected.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(int[] array, int n, int k, RandomStream stream)Similar toshuffle(Object[], n, k, RandomStream).- Parameters:
array- the array being shuffled.n- selection amongst the first n elements.k- number of elements selected.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(long[] array, int n, int k, RandomStream stream)Similar toshuffle(Object[], n, k, RandomStream).- Parameters:
array- the array being shuffled.n- selection amongst the first n elements.k- number of elements selected.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(char[] array, int n, int k, RandomStream stream)Similar toshuffle(Object[], n, k, RandomStream).- Parameters:
array- the array being shuffled.n- selection amongst the first n elements.k- number of elements selected.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(boolean[] array, int n, int k, RandomStream stream)Similar toshuffle(Object[], n, k, RandomStream).- Parameters:
array- the array being shuffled.n- selection amongst the first n elements.k- number of elements selected.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(float[] array, int n, int k, RandomStream stream)Similar toshuffle(Object[], n, k, RandomStream).- Parameters:
array- the array being shuffled.n- selection amongst the first n elements.k- number of elements selected.stream- the random stream used to generate random numbers.
-
shuffle
public static void shuffle(double[] array, int n, int k, RandomStream stream)Similar toshuffle(Object[], n, k, RandomStream).- Parameters:
array- the array being shuffled.n- selection amongst the first n elements.k- number of elements selected.stream- the random stream used to generate random numbers.
-
-
DMelt 3.0 © DataMelt by jWork.ORG