// 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; }
// 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; }