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

Comparing jsr166/src/test/loops/IteratorLoops.java (file contents):
Revision 1.8 by jsr166, Wed Sep 1 07:20:36 2010 UTC vs.
Revision 1.14 by jsr166, Sun Oct 23 03:03:23 2016 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 java.util.*;
# Line 14 | Line 14 | import java.util.*;
14   * and long iterators.  Reports include times for adds and other
15   * checks, so overestimate times per iteration.
16   */
17
17   public final class IteratorLoops {
18      static final int DEFAULT_SIZE = 16384;
19      static final int DEFAULT_TRIALS = 4;
# Line 23 | Line 22 | public final class IteratorLoops {
22      static int randomSeed = 3122688;
23  
24      public static void main(String[] args) throws Exception {
25 <        Class klass = Class.forName(args[0]);
25 >        Class<?> klass = Class.forName(args[0]);
26          int n = (args.length <= 1) ? DEFAULT_SIZE : Integer.parseInt(args[1]);
27          int t = (args.length <= 2) ? DEFAULT_TRIALS : Integer.parseInt(args[2]);
28  
# Line 33 | Line 32 | public final class IteratorLoops {
32          System.out.println();
33  
34          Collection<Integer>[] colls =
35 <            (Collection<Integer>[])new Collection[NC];
35 >            (Collection<Integer>[])new Collection<?>[NC];
36  
37          for (int k = 0; k < colls.length; ++k) {
38 <            Object x = klass.newInstance();
38 >            Object x = klass.getConstructor().newInstance();
39              if (x instanceof Collection)
40                  colls[k] = (Collection<Integer>) x;
41              else if (x instanceof Map)
# Line 87 | Line 86 | public final class IteratorLoops {
86      int counts() {
87          int count = 0;
88          for (int k = 0; k < cs.length; ++k) {
89 <            for (Iterator it = cs[k].iterator(); it.hasNext();) {
90 <                if (it.next() != null)
89 >            for (Integer x : cs[k]) {
90 >                if (x != null)
91                      ++count;
92              }
93          }
# Line 123 | Line 122 | public final class IteratorLoops {
122          try { Thread.sleep(500); }
123          catch (Exception ex) { return; }
124      }
126
127
125   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines