1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
/** |
7 |
|
* Misc utilities in JSR166 performance tests |
108 |
|
int x = -1831433054; |
109 |
|
public XorShift32Random(int seed) { x = seed; } |
110 |
|
public XorShift32Random() { |
111 |
< |
this((int)System.nanoTime() + seq.getAndAdd(129)); |
111 |
> |
this((int) System.nanoTime() + seq.getAndAdd(129)); |
112 |
|
} |
113 |
|
public int next() { |
114 |
|
x ^= x << 6; |
128 |
|
int w = 273326509; |
129 |
|
public MarsagliaRandom(int seed) { x = seed; } |
130 |
|
public MarsagliaRandom() { |
131 |
< |
this((int)System.nanoTime() + seq.getAndAdd(129)); |
131 |
> |
this((int) System.nanoTime() + seq.getAndAdd(129)); |
132 |
|
} |
133 |
|
public int next() { |
134 |
|
int t = x ^ (x << 11); |
143 |
|
* Unsynchronized version of java.util.Random algorithm. |
144 |
|
*/ |
145 |
|
public static final class SimpleRandom { |
146 |
< |
private final static long multiplier = 0x5DEECE66DL; |
147 |
< |
private final static long addend = 0xBL; |
148 |
< |
private final static long mask = (1L << 48) - 1; |
146 |
> |
private static final long multiplier = 0x5DEECE66DL; |
147 |
> |
private static final long addend = 0xBL; |
148 |
> |
private static final long mask = (1L << 48) - 1; |
149 |
|
static final AtomicLong seq = new AtomicLong( -715159705); |
150 |
|
private long seed; |
151 |
|
|
164 |
|
public int next() { |
165 |
|
long nextseed = (seed * multiplier + addend) & mask; |
166 |
|
seed = nextseed; |
167 |
< |
return ((int)(nextseed >>> 17)) & 0x7FFFFFFF; |
167 |
> |
return ((int) (nextseed >>> 17)) & 0x7FFFFFFF; |
168 |
|
} |
169 |
|
} |
170 |
|
|