public class WeightedRandom
extends java.lang.Object
修飾子とタイプ | クラスと説明 |
---|---|
static class |
WeightedRandom.Item |
コンストラクタと説明 |
---|
WeightedRandom() |
修飾子とタイプ | メソッドと説明 |
---|---|
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)