|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jminor.common.model.ItemRandomizerModel<T>
org.jminor.common.model.BoundedItemRandomizerModel<T>
T
- the type of item this random item model returnspublic final class BoundedItemRandomizerModel<T>
A ItemRandomizer with the added constraint that the total item weights can not exceed a defined maximum.
When the weight of one item is incremented the weight of another is decremented in a round robin kind of fashion
and when a item weight is decremented the weight of another is incremented.
User: Björn Darri
Date: 6.4.2010
Time: 21:26:00
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.jminor.common.model.ItemRandomizer |
---|
ItemRandomizer.RandomItem<T> |
Constructor Summary | |
---|---|
BoundedItemRandomizerModel(int boundedWeight,
T... items)
Instantiates a new BoundedRandomItemModel with the given bounded weight. |
|
BoundedItemRandomizerModel(T... items)
Instantiates a new BoundedRandomItemModel with a default bounded weight of 100. |
Method Summary | |
---|---|
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 |
Methods inherited from class org.jminor.common.model.ItemRandomizerModel |
---|
addItem, fireWeightsChangedEvent, getEnabledObserver, getItemCount, getItems, getRandom, getRandomItem, getRandomItem, getWeight, getWeightRatio, getWeightsObserver, isItemEnabled, setItemEnabled |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BoundedItemRandomizerModel(T... items)
items
- the itemspublic BoundedItemRandomizerModel(int boundedWeight, T... items)
boundedWeight
- the maximum total weightitems
- the itemsMethod Detail |
---|
public 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |