Java Code Examples for org.apache.commons.lang3.ArrayUtils#shuffle()
The following examples show how to use
org.apache.commons.lang3.ArrayUtils#shuffle() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LinearSearchSizeDependent.java From adaptive-radix-tree with MIT License | 6 votes |
@Setup public void setup() { int size = 16; keys = new byte[size]; toLookup = new byte[size]; limits = new int[size]; for (int i = 0; i < limits.length; i++) { ThreadLocalRandom.current().nextInt(0, size + 1); } ThreadLocalRandom.current().nextBytes(keys); Arrays.sort(keys); System.arraycopy(keys, 0, toLookup, 0, keys.length); ArrayUtils.shuffle(toLookup); }
Example 2
Source File: DataUtils.java From neodymium-library with MIT License | 6 votes |
/** * A random password that is strong enough for most services * * @return a password */ public static String randomPassword() { final String upper = new RandomStringGenerator.Builder().selectFrom("abcdefghijklmnopqrstuvwxyz".toUpperCase().toCharArray()).build() .generate(Neodymium.configuration().dataUtilsPasswordUppercaseCharAmount()); final String lower = new RandomStringGenerator.Builder().selectFrom("abcdefghijklmnopqrstuvwxyz".toCharArray()).build() .generate(Neodymium.configuration().dataUtilsPasswordLowercaseCharAmount()); final String number = new RandomStringGenerator.Builder().selectFrom("0123456789".toCharArray()).build() .generate(Neodymium.configuration().dataUtilsPasswordDigitAmount()); final String special = new RandomStringGenerator.Builder().selectFrom(Neodymium.configuration().dataUtilsPasswordSpecialChars().toCharArray()).build() .generate(Neodymium.configuration().dataUtilsPasswordSpecialCharAmount()); final char[] all = (upper + lower + number + special).toCharArray(); ArrayUtils.shuffle(all); return new String(all); }
Example 3
Source File: Randoms.java From basic-tools with MIT License | 5 votes |
/** * max 如果是5 返回[0,1,2,3,4]的随机组合 * @param max * @return */ public static int [] getRandomArray(int max){ //循环遍历队列,这个地方不能每次都按照从0 到 ConstantValue.MemberShipPassivityListCount 大小循环 //万一数据多了,0 1 2这几个队列没关系,后边的队列会一直处于饥饿状态的,所以每次随机一下 int[] array = new int[max]; for(int i = 0;i < max;i++){ array[i] = i; } ArrayUtils.shuffle(array); return array; }
Example 4
Source File: LinearSearchFixedSizeUnrolledLoop.java From adaptive-radix-tree with MIT License | 5 votes |
@Setup public void setup() { int size = 4; keys = new byte[size]; toLookup = new byte[size]; ThreadLocalRandom.current().nextBytes(keys); Arrays.sort(keys); System.arraycopy(keys, 0, toLookup, 0, keys.length); ArrayUtils.shuffle(toLookup); }
Example 5
Source File: LinearSearchFixedSizeUnrolledLoop.java From adaptive-radix-tree with MIT License | 5 votes |
@Setup public void setup() { int size = 16; keys = new byte[size]; toLookup = new byte[size]; ThreadLocalRandom.current().nextBytes(keys); Arrays.sort(keys); System.arraycopy(keys, 0, toLookup, 0, keys.length); ArrayUtils.shuffle(toLookup); }
Example 6
Source File: LinearVsBinarySearch.java From adaptive-radix-tree with MIT License | 5 votes |
@Setup public void setup() { keys = new byte[size]; toLookup = new byte[size]; ThreadLocalRandom.current().nextBytes(keys); Arrays.sort(keys); System.arraycopy(keys, 0, toLookup, 0, keys.length); ArrayUtils.shuffle(toLookup); }
Example 7
Source File: ExtraSpaceSentinelLinearSearch.java From adaptive-radix-tree with MIT License | 5 votes |
@Setup public void setup() { keys = new byte[size + 1]; toLookup = new byte[size]; ThreadLocalRandom.current().nextBytes(keys); Arrays.sort(keys); System.arraycopy(keys, 0, toLookup, 0, toLookup.length); ArrayUtils.shuffle(toLookup); }
Example 8
Source File: ArrayOperations.java From tutorials with MIT License | 4 votes |
public static int[] shuffleIntArray(int[] array) { // we create a different array instance for testing purposes int[] shuffled = Arrays.copyOf(array, array.length); ArrayUtils.shuffle(shuffled); return shuffled; }
Example 9
Source File: ArrayOperations.java From tutorials with MIT License | 4 votes |
public static <T> T[] shuffleObjectArray(T[] array) { // we create a different array instance for testing purposes T[] shuffled = Arrays.copyOf(array, array.length); ArrayUtils.shuffle(shuffled); return shuffled; }