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

Comparing jsr166/src/test/loops/MapWordLoops.java (file contents):
Revision 1.5 by jsr166, Thu Oct 29 23:09:07 2009 UTC vs.
Revision 1.11 by jsr166, Thu Jan 15 18:34:19 2015 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 import java.util.*;
6   import java.io.*;
7 + import java.util.*;
8  
9   public class MapWordLoops {
10  
# Line 25 | Line 25 | public class MapWordLoops {
25      static final int numTests = 3;
26  
27      public static void main(String[] args) {
28 <        Class mapClass = null;
28 >        Class<?> mapClass = null;
29          try {
30              mapClass = Class.forName(args[0]);
31 <        } catch(ClassNotFoundException e) {
31 >        } catch (ClassNotFoundException e) {
32              throw new RuntimeException("Class " + args[0] + " not found.");
33          }
34  
# Line 42 | Line 42 | public class MapWordLoops {
42  
43      }
44  
45 <    static void tests(Class mapClass, int numTests, int sizeIndex) {
45 >    static void tests(Class<?> mapClass, int numTests, int sizeIndex) {
46          try {
47              String[] key = readWords(sizeIndex);
48              int size = key.length;
# Line 65 | Line 65 | public class MapWordLoops {
65          }
66      }
67  
68 <
69 <    static Map<String,String> newMap(Class cl) {
68 >    static Map<String,String> newMap(Class<?> cl) {
69          try {
70              Map m = (Map<String,String>)cl.newInstance();
71              return m;
72 <        } catch(Exception e) {
72 >        } catch (Exception e) {
73              throw new RuntimeException("Can't instantiate " + cl + ": " + e);
74          }
75      }
76  
77      static void pause() {
78 <        try { Thread.sleep(100); } catch(InterruptedException ie) { return; }
78 >        try { Thread.sleep(100); }
79 >        catch (InterruptedException ie) { return; }
80      }
81  
82      static String[] readWords(int sizeIndex) throws IOException {
# Line 115 | Line 115 | public class MapWordLoops {
115          long startTime = System.currentTimeMillis();
116          runner.run();
117          long afterRun = System.currentTimeMillis();
118 <        long runTime =  (afterRun - startTime);
118 >        long runTime = afterRun - startTime;
119          int np = runner.total;
120          if (runner.total == runner.hashCode())
121              System.out.println("Useless Number" + runner.total);
# Line 126 | Line 126 | public class MapWordLoops {
126          return runTime;
127      }
128  
129
129      static class Runner implements Runnable {
130          final Map<String,String> map;
131          final String[] key;
# Line 147 | Line 146 | public class MapWordLoops {
146              rng = new LoopHelpers.SimpleRandom((id + 1) * 8862213513L);
147          }
148  
150
149          int oneStep(int j) {
150              int n = key.length;
151              int r = rng.next() & 0x7FFFFFFF;
# Line 176 | Line 174 | public class MapWordLoops {
174                  if (r < pctrem) {
175                      map.remove(k);
176                      ++nremoves;
177 <                    j += ((r >>> 8) & 7) +  n / 2;
177 >                    j += ((r >>> 8) & 7) + n / 2;
178                      if (j >= n) j -= n;
179                  }
180              }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines