Exemplo n.º 1
0
 // Sorts labels from the mapping.  We may get rid of this later perhaps.
 String[] revisedLabels(HashMap map) {
   // Sort labels
   String[] labels = new String[map.size()];
   labels = (String[]) (map.keySet().toArray(labels));
   Arrays.sort(labels);
   return labels;
 }
Exemplo n.º 2
0
 // Returns the counts from the mapping, in the same order as the labels
 double[] amounts(HashMap map, String[] revisedLabels) {
   // Extract amounts
   double[] amounts = new double[map.size()];
   for (int i = 0; i < amounts.length; i++)
     amounts[i] = ((Double) (map.get(revisedLabels[i]))).doubleValue();
   return amounts;
 }
Exemplo n.º 3
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;
 }