53 |
|
eclass = java.lang.Float.class; |
54 |
|
else if (et.startsWith("s")) |
55 |
|
eclass = java.lang.String.class; |
56 |
+ |
else if (et.startsWith("d")) |
57 |
+ |
eclass = java.lang.Double.class; |
58 |
|
} |
59 |
|
if (eclass == null) |
60 |
|
eclass = Object.class; |
237 |
|
static void valTest(Map s, Object[] key) { |
238 |
|
int size = s.size(); |
239 |
|
int sum = 0; |
240 |
< |
timer.start("Traverse access key/val", size); |
240 |
> |
timer.start("Traverse key or value ", size); |
241 |
|
if (s.containsValue(MISSING)) ++sum; |
242 |
|
timer.finish(); |
243 |
|
reallyAssert (sum == 0); |
248 |
|
static Object kitTest(Map s, int size) { |
249 |
|
Object last = null; |
250 |
|
int sum = 0; |
251 |
< |
timer.start("Traverse access key/val", size); |
251 |
> |
timer.start("Traverse key or value ", size); |
252 |
|
for (Iterator it = s.keySet().iterator(); it.hasNext(); ) { |
253 |
|
Object x = it.next(); |
254 |
|
if (x != last && x != null && x.getClass() == eclass) |
264 |
|
static Object vitTest(Map s, int size) { |
265 |
|
Object last = null; |
266 |
|
int sum = 0; |
267 |
< |
timer.start("Traverse access key/val", size); |
267 |
> |
timer.start("Traverse key or value ", size); |
268 |
|
for (Iterator it = s.values().iterator(); it.hasNext(); ) { |
269 |
|
Object x = it.next(); |
270 |
|
if (x != last && x != null && x.getClass() == eclass) |
279 |
|
|
280 |
|
static void eitTest(Map s, int size) { |
281 |
|
int sum = 0; |
282 |
< |
timer.start("Traverse access entry ", size); |
282 |
> |
timer.start("Traverse entry ", size); |
283 |
|
for (Iterator it = s.entrySet().iterator(); it.hasNext(); ) { |
284 |
|
Map.Entry e = (Map.Entry)it.next(); |
285 |
|
Object k = e.getKey(); |
423 |
|
Object hold = s2.get(lastkey); |
424 |
|
int sum = 0; |
425 |
|
|
426 |
< |
timer.start("Traverse access entry ", size * 12); // 12 until finish |
426 |
> |
timer.start("Traverse entry ", size * 12); // 12 until finish |
427 |
|
|
428 |
|
int sh1 = s.hashCode() - s2.hashCode(); |
429 |
|
reallyAssert (sh1 == 0); |
524 |
|
else if (eclass == Float.class) { |
525 |
|
initFloats(key, absent, size); |
526 |
|
} |
527 |
+ |
else if (eclass == Double.class) { |
528 |
+ |
initDoubles(key, absent, size); |
529 |
+ |
} |
530 |
|
else if (eclass == String.class) { |
531 |
|
initWords(size, key, absent); |
532 |
|
} |
563 |
|
if (m.put(ir, ir) == null) |
564 |
|
absent[k++] = ir; |
565 |
|
} |
566 |
+ |
} |
567 |
+ |
|
568 |
+ |
static void initDoubles(Object[] key, Object[] absent, int size) { |
569 |
+ |
Map m = newMap(); |
570 |
+ |
for (int i = 0; i < size; ++i) { |
571 |
+ |
double r = Double.valueOf(i); |
572 |
+ |
key[i] = r; |
573 |
+ |
m.put(r, r); |
574 |
+ |
} |
575 |
+ |
int k = 0; |
576 |
+ |
while (k < size) { |
577 |
+ |
double r = rng.nextDouble(); |
578 |
+ |
Double ir = Double.valueOf(r); |
579 |
+ |
if (m.put(ir, ir) == null) |
580 |
+ |
absent[k++] = ir; |
581 |
+ |
} |
582 |
|
} |
583 |
|
|
584 |
|
// Use as many real words as possible, then use fake random words |