Package org.apache.bookkeeper.client
Class WeightedRandomSelectionImpl<T>
- java.lang.Object
-
- org.apache.bookkeeper.client.WeightedRandomSelectionImpl<T>
-
- All Implemented Interfaces:
WeightedRandomSelection<T>
class WeightedRandomSelectionImpl<T> extends java.lang.Object implements WeightedRandomSelection<T>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.bookkeeper.client.WeightedRandomSelection
WeightedRandomSelection.WeightedObject
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.TreeMap<java.lang.Double,T>
cumulativeMap
(package private) static org.slf4j.Logger
LOG
(package private) java.util.Map<T,WeightedRandomSelection.WeightedObject>
map
(package private) int
maxProbabilityMultiplier
(package private) java.lang.Double
randomMax
(package private) java.util.concurrent.locks.ReadWriteLock
rwLock
-
Constructor Summary
Constructors Constructor Description WeightedRandomSelectionImpl()
WeightedRandomSelectionImpl(int maxMultiplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
getNextRandom()
T
getNextRandom(java.util.Collection<T> selectedNodes)
void
setMaxProbabilityMultiplier(int max)
void
updateMap(java.util.Map<T,WeightedRandomSelection.WeightedObject> map)
-
-
-
Field Detail
-
LOG
static final org.slf4j.Logger LOG
-
randomMax
java.lang.Double randomMax
-
maxProbabilityMultiplier
int maxProbabilityMultiplier
-
map
java.util.Map<T,WeightedRandomSelection.WeightedObject> map
-
cumulativeMap
java.util.TreeMap<java.lang.Double,T> cumulativeMap
-
rwLock
java.util.concurrent.locks.ReadWriteLock rwLock
-
-
Method Detail
-
updateMap
public void updateMap(java.util.Map<T,WeightedRandomSelection.WeightedObject> map)
- Specified by:
updateMap
in interfaceWeightedRandomSelection<T>
-
getNextRandom
public T getNextRandom()
- Specified by:
getNextRandom
in interfaceWeightedRandomSelection<T>
-
setMaxProbabilityMultiplier
public void setMaxProbabilityMultiplier(int max)
- Specified by:
setMaxProbabilityMultiplier
in interfaceWeightedRandomSelection<T>
-
getNextRandom
public T getNextRandom(java.util.Collection<T> selectedNodes)
- Specified by:
getNextRandom
in interfaceWeightedRandomSelection<T>
-
-