22 |
|
U base) { |
23 |
|
int n = array.length; |
24 |
|
U x = base; |
25 |
< |
for (int i = 0; i < n; ++i) |
25 |
> |
for (int i = 0; i < n; ++i) |
26 |
|
x = reducer.op(x, mapper.op(array[i])); |
27 |
|
return x; |
28 |
|
} |
29 |
|
|
30 |
< |
|
30 |
> |
|
31 |
|
|
32 |
|
// sample functions |
33 |
|
static final class GetNext implements Ops.Op<Rand, Long> { |
34 |
< |
public Long op(Rand x) { |
34 |
> |
public Long op(Rand x) { |
35 |
|
return x.next(); |
36 |
|
} |
37 |
|
} |
51 |
|
int n = 1 << 18; |
52 |
|
int reps = 1 << 8; |
53 |
|
Rand[] array = new Rand[n]; |
54 |
< |
for (int i = 0; i < n; ++i) |
54 |
> |
for (int i = 0; i < n; ++i) |
55 |
|
array[i] = new Rand(i+1); |
56 |
|
ForkJoinPool fjp = new ForkJoinPool(1); |
57 |
|
ParallelArray<Rand> pa = ParallelArray.createUsingHandoff(array, fjp); |
130 |
|
} |
131 |
|
public long next() { |
132 |
|
long x = seed; |
133 |
< |
x ^= x << 13; |
134 |
< |
x ^= x >>> 7; |
133 |
> |
x ^= x << 13; |
134 |
> |
x ^= x >>> 7; |
135 |
|
x ^= (x << 17); |
136 |
|
seed = x; |
137 |
|
return x; |