--- jsr166/src/test/loops/MapWordLoops.java 2009/10/29 23:09:07 1.5 +++ jsr166/src/test/loops/MapWordLoops.java 2014/12/31 17:00:58 1.10 @@ -1,10 +1,10 @@ /* * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain + * http://creativecommons.org/publicdomain/zero/1.0/ */ -import java.util.*; import java.io.*; +import java.util.*; public class MapWordLoops { @@ -25,10 +25,10 @@ public class MapWordLoops { static final int numTests = 3; public static void main(String[] args) { - Class mapClass = null; + Class mapClass = null; try { mapClass = Class.forName(args[0]); - } catch(ClassNotFoundException e) { + } catch (ClassNotFoundException e) { throw new RuntimeException("Class " + args[0] + " not found."); } @@ -42,7 +42,7 @@ public class MapWordLoops { } - static void tests(Class mapClass, int numTests, int sizeIndex) { + static void tests(Class mapClass, int numTests, int sizeIndex) { try { String[] key = readWords(sizeIndex); int size = key.length; @@ -66,17 +66,18 @@ public class MapWordLoops { } - static Map newMap(Class cl) { + static Map newMap(Class cl) { try { Map m = (Map)cl.newInstance(); return m; - } catch(Exception e) { + } catch (Exception e) { throw new RuntimeException("Can't instantiate " + cl + ": " + e); } } static void pause() { - try { Thread.sleep(100); } catch(InterruptedException ie) { return; } + try { Thread.sleep(100); } + catch (InterruptedException ie) { return; } } static String[] readWords(int sizeIndex) throws IOException { @@ -115,7 +116,7 @@ public class MapWordLoops { long startTime = System.currentTimeMillis(); runner.run(); long afterRun = System.currentTimeMillis(); - long runTime = (afterRun - startTime); + long runTime = afterRun - startTime; int np = runner.total; if (runner.total == runner.hashCode()) System.out.println("Useless Number" + runner.total); @@ -176,7 +177,7 @@ public class MapWordLoops { if (r < pctrem) { map.remove(k); ++nremoves; - j += ((r >>> 8) & 7) + n / 2; + j += ((r >>> 8) & 7) + n / 2; if (j >= n) j -= n; } }