T
- the type of item this random item model returnspublic final class BoundedItemRandomizerModel<T> extends ItemRandomizerModel<T>
ItemRandomizer.RandomItem<T>
Constructor and Description |
---|
BoundedItemRandomizerModel(java.util.Collection<T> items)
Instantiates a new BoundedRandomItemModel with a default bounded weight of 100.
|
BoundedItemRandomizerModel(int boundedWeight,
java.util.Collection<T> items)
Instantiates a new BoundedRandomItemModel with the given bounded weight.
|
Modifier and Type | Method and Description |
---|---|
void |
addItem(T item,
int weight)
Adds the given item to this model with the given weight value.
|
void |
decrementWeight(T item)
Decrements the weight of the given item by one
|
int |
getWeightBounds() |
void |
incrementWeight(T item)
Increments the weight of the given item by one
|
void |
setWeight(T item,
int weight)
Sets the weight of the given item
|
addItem, fireWeightsChangedEvent, getEnabledObserver, getItemCount, getItems, getRandom, getRandomItem, getRandomItem, getWeight, getWeightRatio, getWeightsObserver, isItemEnabled, setItemEnabled
public BoundedItemRandomizerModel(java.util.Collection<T> items)
items
- the itemspublic BoundedItemRandomizerModel(int boundedWeight, java.util.Collection<T> items)
boundedWeight
- the maximum total weightitems
- the itemspublic int getWeightBounds()
public void incrementWeight(T item)
incrementWeight
in interface ItemRandomizer<T>
incrementWeight
in class ItemRandomizerModel<T>
item
- the itempublic void decrementWeight(T item)
decrementWeight
in interface ItemRandomizer<T>
decrementWeight
in class ItemRandomizerModel<T>
item
- the itempublic void setWeight(T item, int weight)
setWeight
in interface ItemRandomizer<T>
setWeight
in class ItemRandomizerModel<T>
item
- the itemweight
- the valuepublic void addItem(T item, int weight)
addItem
in interface ItemRandomizer<T>
addItem
in class ItemRandomizerModel<T>
item
- the item to addweight
- the initial weight to assign to the item