public class WeightedRandom
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
WeightedRandom.Item |
Constructor and Description |
---|
WeightedRandom() |
Modifier and Type | Method and Description |
---|---|
static <T extends WeightedRandom.Item> |
getRandomItem(java.util.List<T> collection,
int weight) |
static <T extends WeightedRandom.Item> |
getRandomItem(java.util.Random random,
java.util.List<T> collection)
Returns a random choice from the input items.
|
static <T extends WeightedRandom.Item> |
getRandomItem(java.util.Random random,
java.util.List<T> collection,
int totalWeight)
Returns a random choice from the input items, with a total weight value.
|
static int |
getTotalWeight(java.util.List<? extends WeightedRandom.Item> collection)
Returns the total weight of all items in a collection.
|
public static int getTotalWeight(java.util.List<? extends WeightedRandom.Item> collection)
public static <T extends WeightedRandom.Item> T getRandomItem(java.util.Random random, java.util.List<T> collection, int totalWeight)
public static <T extends WeightedRandom.Item> T getRandomItem(java.util.List<T> collection, int weight)
public static <T extends WeightedRandom.Item> T getRandomItem(java.util.Random random, java.util.List<T> collection)