31 |
|
* |
32 |
|
* For String keys, the program tries to use file "testwords.txt", which |
33 |
|
* is best used with real words. We can't check in this file, but you |
34 |
< |
* can create one from a real dictonary (1 line per word) and then run |
34 |
> |
* can create one from a real dictionary (1 line per word) and then run |
35 |
|
* linux "shuf" to randomize entries. If no file exists, it uses |
36 |
|
* String.valueOf(i) for element i. |
37 |
|
*/ |
236 |
|
public long work(int len, int minIters, int maxIters, long timeLimit) { |
237 |
|
Map m; |
238 |
|
try { |
239 |
< |
m = (Map)mapClass.newInstance(); |
240 |
< |
} catch(Exception e) { |
239 |
> |
m = (Map) mapClass.newInstance(); |
240 |
> |
} catch (Exception e) { |
241 |
|
throw new RuntimeException("Can't instantiate " + mapClass + ": " + e); |
242 |
|
} |
243 |
|
Object[] ins = items; |
365 |
|
// more realistic |
366 |
|
static void scramble(Object[] a) { |
367 |
|
for (int k = 0; k < sizes.length; ++k) { |
368 |
< |
int origin = k == 0? 0 : sizes[k-1]; |
368 |
> |
int origin = (k == 0) ? 0 : sizes[k-1]; |
369 |
|
for (int i = sizes[k]; i > origin + 1; i--) { |
370 |
|
Object t = a[i-1]; |
371 |
|
int r = rng.nextInt(i - origin) + origin; |