List of utility methods to do List Random Item
List | asRandomAccessList(Collection Returns a list implementation that allows for efficient random access. if (list instanceof List<?> && list instanceof RandomAccess) { return (List<T>) list; return new ArrayList<T>(list); |
T | choice(List Returns a random element a list. return list.get(GENERATOR.nextInt(list.size()));
|
T | choice(T... list) choice return choice(asList(list));
|
T | choose(Random random, List choose if (random == null) return list.get(0); return list.get(random.nextInt(list.size())); |
T | chooseRandom(List choose Random return list.get(random(0, list.size() - 1));
|
Type | chooseRandomElement(List choose Random Element final int index = random.nextInt(list.size()); return list.get(index); |
List
| computeCrossProduct(List extends Collection Create the cross product of a list of list. if (maximumSize < 1) { return null; double Q = -1.0; if (maximumSize < Integer.MAX_VALUE) { int size = 1; int counter = 0; for (Collection<E> possibilities : allArgPossibilities) { ... |
int | findFirst(List extends T> list, T value, Comparator super T> comparator) Finds the first index where the value is located or the index where it could be inserted, similar to the regular binarySearch() methods, but it works with duplicate elements. return findFirst(list, 0, list.size(), value, comparator);
|
Integer | generateInteger(int min, int maxInclusive, List generate Integer int random = generateInteger(min, maxInclusive); boolean found = false; for (Integer val : excludedValues) { if (val == random) { found = true; if (found) { ... |
T | getRandomElement(final List Returns a random element from the specified container. final int randomIndex = randomGenerator.nextInt(list.size()); return list.get(randomIndex); |