use of java.util.SplittableRandom in project jdk8u_jdk by JetBrains.
the class SplittableRandomTest method testBoundedInts.
/**
* Each of a parallel sized stream of bounded ints is within bounds
*/
public void testBoundedInts() {
AtomicInteger fails = new AtomicInteger(0);
SplittableRandom r = new SplittableRandom();
long size = 12345L;
for (int least = -15485867; least < MAX_INT_BOUND; least += 524959) {
for (int bound = least + 2; bound > least && bound < MAX_INT_BOUND; bound += 67867967) {
final int lo = least, hi = bound;
r.ints(size, lo, hi).parallel().forEach(x -> {
if (x < lo || x >= hi)
fails.getAndIncrement();
});
}
}
assertEquals(fails.get(), 0);
}
use of java.util.SplittableRandom in project jdk8u_jdk by JetBrains.
the class SplittableRandomTest method testNextLongBadBounds.
/**
* nextLong(least >= bound) throws IllegalArgumentException
*/
@Test(expectedExceptions = IllegalArgumentException.class)
public void testNextLongBadBounds() {
SplittableRandom sr = new SplittableRandom();
long f = sr.nextLong(17, 2);
}
use of java.util.SplittableRandom in project jdk8u_jdk by JetBrains.
the class SplittableRandomTest method testSplit1.
/**
* A SplittableRandom produced by split() of a default-constructed
* SplittableRandom generates a different sequence
*/
public void testSplit1() {
SplittableRandom sr = new SplittableRandom();
for (int reps = 0; reps < REPS; ++reps) {
SplittableRandom sc = sr.split();
int i = 0;
while (i < NCALLS && sr.nextLong() == sc.nextLong()) ++i;
assertTrue(i < NCALLS);
}
}
use of java.util.SplittableRandom in project jdk8u_jdk by JetBrains.
the class SplittableRandomTest method testDoublesCount.
/**
* A parallel sized stream of doubles generates the given number of values
*/
public void testDoublesCount() {
LongAdder counter = new LongAdder();
SplittableRandom r = new SplittableRandom();
long size = 0;
for (int reps = 0; reps < REPS; ++reps) {
counter.reset();
r.doubles(size).parallel().forEach(x -> {
counter.increment();
});
assertEquals(counter.sum(), size);
size += 524959;
}
}
use of java.util.SplittableRandom in project intellij-community by JetBrains.
the class Main method generateLimit.
public static void generateLimit() {
Integer acc = 0;
SplittableRandom splittableRandom = new SplittableRandom(1);
for (long count = 100; count > 0; count--) {
Integer integer = 500;
acc = splittableRandom.nextInt(acc, integer);
}
int n1 = acc;
System.out.println(n1);
}
Aggregations