static int random(int n, Random r default defaultRandomGenerator()) {
ret random(r, n);
}
static long random(long n, Random r default defaultRandomGenerator()) {
ret random(r, n);
}
static int random(Random r, int n) {
return n <= 0 ? 0 : getRandomizer(r).nextInt(n);
}
static long random(Random r, long n) {
return n <= 0 ? 0 : getRandomizer(r).nextLong(n);
}
static double random(double max) {
return random()*max;
}
static double random() {
return defaultRandomGenerator().nextInt(100001)/100000.0;
}
static double random(double min, double max) {
return min+random()*(max-min);
}
// min <= value < max
static int random(int min, int max) {
return min+random(max-min);
}
// min <= value < max
static long random(long min, long max) {
return min+random(max-min);
}
static int random(int min, int max, Random r) {
ret random(r, min, max);
}
static int random(Random r, int min, int max) {
return min+random(r, max-min);
}
static A random(L l) {
ret oneOf(l);
}
static A random(Collection c) {
if (c instanceof L) ret random((L) c);
int i = random(l(c));
ret collectionGet(c, i);
}
ifclass IntRange
static int random(IntRange r) {
ret random(r.start, r.end);
}
endif
ifclass DoubleRange
static double random(DoubleRange r) {
ret random(r.start, r.end);
}
endif
ifclass TimestampRange
static Timestamp random(TimestampRange r) {
ret r == null ?: new Timestamp(random(r.startTime().unixDate(),
r.endTime().unixDate()));
}
endif
static Pair random(Map map) {
ret entryToPair(random(entries(map)));
}