List of utility methods to do Random Int
String | randomWord(int wordLength) random Word StringBuffer word = new StringBuffer(); for (int i = 0; i < wordLength; i++) { int index = Math.abs((int) (Math.random() * WORD.length())); char ch = WORD.charAt(index); word.append(ch); return word.toString(); |
String | randomZeroString(int length) random Zero String StringBuffer sb = new StringBuffer(); for (int i = 0; i < length; i++) { sb.append("0"); return sb.toString(); |
int | randowPartition(int[] array, int q, int p) randow Partition int pivotIndex = q + (int) Math.round((p - q - 1) * Math.random()); int pivot = array[pivotIndex]; int[] leftArray = new int[p - q + 1]; int[] rightArray = new int[p - q + 1]; int ll = 0, rl = 0; for (int i = q; i < p; i++) { if (array[i] <= pivot && i != pivotIndex) { leftArray[ll] = array[i]; ... |
int[] | randProductNumerid(final int c, final int count) rand Product Numerid int ret[] = new int[c]; int i = 0; while (true) { if (i == c) { break; int a = (int) Math.ceil(Math.random() * count); if (!isExist(a, ret)) { ... |
int | RandSelect(int iTotal) Rand Select double a; a = Math.random(); a = a * iTotal; return ((int) a); |