3 |
|
* Expert Group and released to the public domain, as explained at |
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 CollectionWordLoops { |
10 |
|
|
23 |
|
static final int numTests = 2; |
24 |
|
|
25 |
|
public static void main(String[] args) { |
26 |
< |
Class collectionClass = null; |
26 |
> |
Class<?> collectionClass = null; |
27 |
|
try { |
28 |
|
collectionClass = Class.forName(args[0]); |
29 |
|
} catch (ClassNotFoundException e) { |
40 |
|
|
41 |
|
} |
42 |
|
|
43 |
< |
static void tests(Class collectionClass, int numTests, int sizeIndex) { |
43 |
> |
static void tests(Class<?> collectionClass, int numTests, int sizeIndex) { |
44 |
|
try { |
45 |
|
String[] key = readWords(sizeIndex); |
46 |
|
int size = key.length; |
63 |
|
} |
64 |
|
} |
65 |
|
|
66 |
< |
|
67 |
< |
static Collection<String> newCollection(Class cl) { |
66 |
> |
static Collection<String> newCollection(Class<?> cl) { |
67 |
|
try { |
68 |
|
Collection m = (Collection<String>) cl.newInstance(); |
69 |
|
return m; |
113 |
|
long startTime = System.currentTimeMillis(); |
114 |
|
runner.run(); |
115 |
|
long afterRun = System.currentTimeMillis(); |
116 |
< |
long runTime = (afterRun - startTime); |
116 |
> |
long runTime = afterRun - startTime; |
117 |
|
int np = runner.total; |
118 |
|
if (runner.total == runner.hashCode()) |
119 |
|
System.out.println("Useless Number" + runner.total); |
124 |
|
return runTime; |
125 |
|
} |
126 |
|
|
128 |
– |
|
127 |
|
static class Runner implements Runnable { |
128 |
|
final Collection<String> collection; |
129 |
|
final String[] key; |
143 |
|
pctins = (int)(((long)pinsert * (long)(Integer.MAX_VALUE/2)) / 50); |
144 |
|
} |
145 |
|
|
148 |
– |
|
146 |
|
int oneStep(int j) { |
147 |
|
int n = key.length; |
148 |
|
int r = rng.next() & 0x7FFFFFFF; |
170 |
|
if (r < pctrem) { |
171 |
|
collection.remove(k); |
172 |
|
++nremoves; |
173 |
< |
j += ((r >>> 8) & 7) + n / 2; |
173 |
> |
j += ((r >>> 8) & 7) + n / 2; |
174 |
|
if (j >= n) j -= n; |
175 |
|
} |
176 |
|
} |