ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/extra166y/SetOpsDemo.java
(Generate patch)

Comparing jsr166/src/test/extra166y/SetOpsDemo.java (file contents):
Revision 1.1 by dl, Sun Nov 1 22:00:35 2009 UTC vs.
Revision 1.5 by jsr166, Tue Mar 15 19:47:04 2011 UTC

# Line 1 | Line 1
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   import jsr166y.*;
# Line 16 | Line 16 | class SetOpsDemo {
16      static int reps = 16;
17      static final long maxValue = 1 << 12;
18  
19 <    public static void main (String[] args) throws Exception {
19 >    public static void main(String[] args) throws Exception {
20          int n = 1 << 20;
21          Long[] a = new Long[n];
22          ParallelArray<Long> pa = ParallelArray.createUsingHandoff(a, fjpool);
# Line 47 | Line 47 | class SetOpsDemo {
47      }
48  
49      static class Evens implements Ops.IntToObject<Long> {
50 <        public Long op(int i) {
50 >        public Long op(int i) {
51              return Long.valueOf((long)(i << 1));
52          }
53      }
# Line 252 | Line 252 | class SetOpsDemo {
252  
253      // ............
254  
255 <    static void seqRemoveAll(ParallelArray<Long> pa,
255 >    static void seqRemoveAll(ParallelArray<Long> pa,
256                               Ops.Predicate<Long> selector) {
257          Long[] a = pa.getArray();
258          int n = pa.size();
# Line 267 | Line 267 | class SetOpsDemo {
267          pa.setLimit(k);
268      }
269  
270 <    static ArrayList<Long> seqSelectAll(ParallelArray<Long> pa,
270 >    static ArrayList<Long> seqSelectAll(ParallelArray<Long> pa,
271                                          Ops.Predicate<Long> selector) {
272          ArrayList<Long> al = new ArrayList<Long>();
273          Long[] a = pa.getArray();
# Line 283 | Line 283 | class SetOpsDemo {
283      static Long[] seqUnique(Long[] a) {
284          int n = a.length;
285          HashSet<Long> m = new HashSet<Long>(n);
286 <        for (int i = 0; i < n; ++i)
286 >        for (int i = 0; i < n; ++i)
287              m.add(a[i]);
288          int ul = m.size();
289          Long[] u = new Long[ul];
# Line 292 | Line 292 | class SetOpsDemo {
292              u[k++] = e;
293          return u;
294      }
295 <    
296 <    static void checkSorted (ParallelArray<Long> pa)  {
295 >
296 >    static void checkSorted(ParallelArray<Long> pa) {
297          int n = pa.size();
298          for (int i = 0; i < n - 1; i++) {
299              if (pa.get(i).compareTo(pa.get(i+1)) >= 0) {
# Line 301 | Line 301 | class SetOpsDemo {
301              }
302          }
303      }
304 <    
304 >
305      static final class RandomLongGenerator implements Ops.Generator<Long> {
306          public Long op() {
307              return new Long(ThreadLocalRandom.current().nextLong(maxValue));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines