public class ArrayUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
shuffle(int[] array,
int from,
int to,
Random rand)
Shuffles the values in the given array
|
static void |
shuffle(int[] array,
Random rand)
Swaps values in the given array
|
static void |
swap(int[] array,
int a,
int b)
Swaps two indices in the given array
|
public static void shuffle(int[] array, Random rand)
array
- the array to swap values inrand
- the source of randomness for shufflingpublic static void shuffle(int[] array, int from, int to, Random rand)
array
- the array to shuffle values infrom
- the first index, inclusive, to shuffle fromto
- the last index, exclusive, to shuffle fromrand
- the source of randomness for shufflingpublic static void swap(int[] array, int a, int b)
array
- the array to perform the sawp ina
- the first indexb
- the second indexCopyright © 2017. All rights reserved.