T
- The type of object to be held in the table@Beta public class ProbabilityTable<T> extends Object implements Serializable
Constructor and Description |
---|
ProbabilityTable()
Creates a new probability table.
|
ProbabilityTable(RNG rng)
Creates a new probability table with the provided source of randomness
used.
|
Modifier and Type | Method and Description |
---|---|
void |
add(T item,
int weight)
Adds the given item to the table.
|
Set<T> |
items()
Provides a set of the items in this table, without reference to their
weight.
|
T |
random()
Returns an object randomly based on assigned weights.
|
int |
weight(T item)
Returns the weight of the item if the item is in the table.
|
public ProbabilityTable()
public ProbabilityTable(RNG rng)
rng
- the source of randomnesspublic T random()
public void add(T item, int weight)
item
- the object to be addedweight
- the weight to be given to the added objectpublic int weight(T item)
item
- the item searched forCopyright © 2012–2016. All rights reserved.