List of utility methods to do Random Element
T | randomEle(List random Ele return randomEle(list, list.size());
|
Byte | randomElem(Random rand, Set random Elem int item = rand.nextInt(partitions.size()); int i = 0; for (Byte obj : partitions) { if (i == item) return obj; i = i + 1; return partitions.iterator().next(); ... |
E | randomElement(Collection extends E> coll) random Element return randomElement(coll, new Random()); |
E | randomElement(E[] array) random Element return array[randomPositiveInt() % array.length];
|
E | randomElement(final Set random Element final int size = set.size(); final int index = RANDOM_GENERATOR.nextInt(size); int i = 0; for (final E element : set) { if (i == index) { return element; i++; ... |
int | randomElement(int[] anArray) random Element if (anArray.length == 0) { return 0; return anArray[nextInt(anArray.length)]; |
T | randomElement(List Selects a random element from a list. if (list.isEmpty()) throw new IllegalArgumentException("Can't select random element from an empty list."); return list.get(random.get().nextInt(list.size())); |
T | randomElement(T... values) random Element if (values.length == 0) throw new IllegalArgumentException("Cannot choose random value from an empty array"); return values[random.nextInt(values.length)]; |
T | randomElement(T[] array) Picks a random element out of any array type. return array[(int) (RANDOM.nextDouble() * array.length)]; |
T | randomElementOf(final List Get a random element from the list. if (list.isEmpty()) { return null; return list.get(nextInt(0, list.size())); |