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

Comparing jsr166/src/test/loops/MapCheck.java (file contents):
Revision 1.4 by dl, Wed Jul 1 12:11:44 2009 UTC vs.
Revision 1.5 by dl, Wed Jul 22 16:19:51 2009 UTC

# Line 53 | Line 53 | public class MapCheck {
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;
# Line 235 | Line 237 | public class MapCheck {
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);
# Line 246 | Line 248 | public class MapCheck {
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)
# Line 262 | Line 264 | public class MapCheck {
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)
# Line 277 | Line 279 | public class MapCheck {
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();
# Line 421 | Line 423 | public class MapCheck {
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);
# Line 522 | Line 524 | public class MapCheck {
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          }
# Line 558 | Line 563 | public class MapCheck {
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines