Package openbook.util
Class Randomizer
- java.lang.Object
- 
- openbook.util.Randomizer
 
- 
 public class Randomizer extends java.lang.ObjectA set of static utility functions for simulating pseudo-randomness.- Author:
- Pinaki Poddar
 
- 
- 
Constructor SummaryConstructors Constructor Description Randomizer()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanprobability(double p)Returns true with a probability of p.static doublerandom(double min, double max)static intrandom(int n)Picks a random number between 0 (inclusive) and N (exclusive).static intrandom(int min, int max)Picks a uniformly distributed random integer within the given range.static java.lang.StringrandomString(int... segments)Generates a random alphanumeric String with each segment separated by a dash.static <T> TselectRandom(java.util.List<T> list)Picks a random element from the given list.static <T> java.util.List<T>selectRandom(java.util.List<T> list, int n)Selects n elements randomly from the given list.
 
- 
- 
- 
Method Detail- 
probabilitypublic static boolean probability(double p) Returns true with a probability of p.
 - 
randompublic static int random(int n) Picks a random number between 0 (inclusive) and N (exclusive).
 - 
randompublic static int random(int min, int max)Picks a uniformly distributed random integer within the given range.
 - 
randompublic static double random(double min, double max)
 - 
randomStringpublic static java.lang.String randomString(int... segments) Generates a random alphanumeric String with each segment separated by a dash.
 - 
selectRandompublic static <T> T selectRandom(java.util.List<T> list) Picks a random element from the given list.
 - 
selectRandompublic static <T> java.util.List<T> selectRandom(java.util.List<T> list, int n)Selects n elements randomly from the given list.
 
- 
 
-