diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-11-16 10:53:39 -0500 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-11-16 10:53:39 -0500 |
| commit | d02e409ef8a389101970e70a105d30b7b1948ecf (patch) | |
| tree | 389040a41bcbeb6722039ae2917b261a0a4d29ec | |
| parent | ba9cf27de7e9f31dfa97a7266979f300101d67f9 (diff) | |
Update
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/data/SingleSupplier.java | 16 | ||||
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/gen/WeightedRandom.java | 2 |
3 files changed, 19 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d42b71 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +*.swp
\ No newline at end of file diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/SingleSupplier.java b/BJC-Utils2/src/main/java/bjc/utils/data/SingleSupplier.java index f40ab29..ad00496 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/SingleSupplier.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/SingleSupplier.java @@ -2,6 +2,16 @@ package bjc.utils.data; import java.util.function.Supplier; +/** + * A supplier that can only supply one value. + * + * Attempting to retrieve another value will cause an exception to be + * thrown. + * + * @author ben + * + * @param <T> + */ public class SingleSupplier<T> implements Supplier<T> { private static long nextID = 0; @@ -15,6 +25,12 @@ public class SingleSupplier<T> implements Supplier<T> { // instantiation was, in case of duplicate initiations private Exception instSite; + /** + * Create a new single supplier from an existing value + * + * @param supp + * The supplier to give a single value from + */ public SingleSupplier(Supplier<T> supp) { source = supp; 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 e345424..4819ca2 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedRandom.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedRandom.java @@ -116,4 +116,4 @@ public class WeightedRandom<E> { public IList<IPair<Integer, E>> getValues() { return probabilities.pairWith(results); } -}
\ No newline at end of file +} |
