| Modifier and Type | Field and Description |
|---|---|
static Random |
RAND
A simple
Random instance, should only be used on the program's main thread |
static SecureRandom |
SECURE_RAND
Represents a
SecureRandom with a new, randomly generated seed of
a pseudo-random bitlength every 10 minutes. |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
get(Collection<T> collection)
Returns a random element from a collection
|
static <T> List<T> |
get(Collection<T> collection,
int amount)
Returns a list of random, unique elements from a collection
|
static <T> T |
getFromWeightedMap(Map<T,Double> weights)
Returns a random variable from a weighted map, which is a map of objects to their respective
probabilities.
|
static ThreadLocalRandom |
THREAD_LOCAL()
Returns the
ThreadLocalRandom specific to the calling thread |
public static final Random RAND
Random instance, should only be used on the program's main threadpublic static final SecureRandom SECURE_RAND
SecureRandom with a new, randomly generated seed of
a pseudo-random bitlength every 10 minutes.public static final ThreadLocalRandom THREAD_LOCAL()
ThreadLocalRandom specific to the calling threadThreadLocalRandom for the current thread contextpublic static <T> T get(Collection<T> collection)
T - The type of the collection and returned elementcollection - The Collection to get an element frompublic static <T> List<T> get(Collection<T> collection, int amount)
T - The type of the elements in the collection, and what's returnedcollection - The Collection to get elements fromamount - The amount of elements to retrieveList of unique, random elementsIllegalArgumentException - If amount > collection#sizeIllegalArgumentException - If collection is nullpublic static <T> T getFromWeightedMap(Map<T,Double> weights)
weight/map weight, where map weight is the
sum of all the weights in the map. The weights do not have to add up to 1 or 100 or any
arbitrary number.T - The type of the objects being weighted in the Mapweights - A Map<T, Double> of weighted objectsMapCopyright © 2017. All rights reserved.