Package net.glowstone.util
Class WeightedRandom
java.lang.Object
net.glowstone.util.WeightedRandom
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends WeightedRandom.Choice>
TSelects a random item from a weighted distribution.
-
Constructor Details
-
WeightedRandom
public WeightedRandom()
-
-
Method Details
-
getRandom
public static <T extends WeightedRandom.Choice> T getRandom(Random random, Iterable<T> possibilities) Selects a random item from a weighted distribution.- Type Parameters:
T
- the type of each of thepossibilities
- Parameters:
random
- the PRNG to usepossibilities
- the distribution to sample from- Returns:
- a random item
-