Package com.sk89q.worldedit.util
Class WeightedChoice<T>
java.lang.Object
com.sk89q.worldedit.util.WeightedChoice<T>
- Type Parameters:
T
- the type of choice
Returns the best choice given a weighting function and a target weight.
A function must be supplied that returns a numeric score for each choice. The function can return null to mean that the choice should not be considered.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A tuple of choice and score. -
Constructor Summary
ConstructorDescriptionWeightedChoice
(Function<T, ? extends Number> function, double target) Create a new instance. -
Method Summary
-
Constructor Details
-
WeightedChoice
Create a new instance.- Parameters:
function
- a function that assigns a score for each choicetarget
- the target score that the best choice should be closest to
-
-
Method Details
-
consider
Consider the given object.- Parameters:
object
- the choice
-
getChoice
Get the best choice.- Returns:
- the best choice
-