Ejemplo n.º 1
0
 // Takes objects and produces an object->count mapping
 HashMap convertIntoAmountsAndLabels(Object[] objs) {
   // Total the amounts
   HashMap map = new HashMap();
   for (int i = 0; i < objs.length; i++) {
     String label = "null";
     if (objs[i] != null) label = objs[i].toString();
     if (map.containsKey(label))
       map.put(label, new Double(((Double) (map.get(label))).doubleValue() + 1));
     else map.put(label, new Double(1));
   }
   return map;
 }