diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-13 16:54:12 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-13 16:54:12 -0400 |
| commit | ba07771f8333f1b098ab8a9ec9fec886b72b9cc0 (patch) | |
| tree | 7d1326235d021cb4767065cddd25bbe9fbdf5ce1 /BJC-Utils2/src/main/java/bjc/utils/gen | |
| parent | 12637af8d6b7b9b2d96deb89e5a09e05178a8e65 (diff) | |
Removed old data types
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/gen')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/gen/WeightedRandom.java | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedRandom.java b/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedRandom.java index 10da34e..f10ee26 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedRandom.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedRandom.java @@ -1,11 +1,12 @@ package bjc.utils.gen; import java.util.Random; + +import bjc.utils.data.experimental.IHolder; +import bjc.utils.data.experimental.IPair; +import bjc.utils.data.experimental.Identity; import bjc.utils.funcdata.FunctionalList; import bjc.utils.funcdata.IFunctionalList; -import bjc.utils.data.GenHolder; -import bjc.utils.data.IHolder; -import bjc.utils.data.IPair; /** * Represents a random number generator where certain results are weighted @@ -25,14 +26,14 @@ public class WeightedRandom<E> { /** * The list of possible results to pick from */ - private IFunctionalList<E> results; + private IFunctionalList<E> results; /** * The source for any needed random numbers */ - private Random source; + private Random source; - private int totalChance; + private int totalChance; /** * Create a new weighted random generator with the specified source of @@ -74,10 +75,10 @@ public class WeightedRandom<E> { * @return A random value selected in a weighted fashion. */ public E generateValue() { - GenHolder<Integer> randomValue = - new GenHolder<>(source.nextInt(totalChance)); - IHolder<E> currentResult = new GenHolder<>(); - GenHolder<Boolean> valuePicked = new GenHolder<>(true); + IHolder<Integer> randomValue = new Identity<>( + source.nextInt(totalChance)); + IHolder<E> currentResult = new Identity<>(); + IHolder<Boolean> valuePicked = new Identity<>(true); probabilities.forEachIndexed((itemIndex, itemProbability) -> { if (valuePicked.unwrap(bool -> bool)) { |
