Beispiel #1
0
  public StringIntPair[] getCounts(String key) {
    ObjectIntHashMap<String> map = get(key);
    if (map == null) return null;
    String value;
    int i = 0;

    StringIntPair[] ps = new StringIntPair[map.size() - 1];

    for (ObjectCursor<String> cur : map.keys()) {
      if (!(value = cur.value).equals(TOTAL)) ps[i++] = new StringIntPair(value, map.get(value));
    }

    return ps;
  }
Beispiel #2
0
  public ObjectIntPair<String> getBestCount(String key) {
    ObjectIntHashMap<String> map = get(key);

    if (map != null) {
      ObjectIntPair<String> max = new ObjectIntPair<String>(null, -1);
      int count;

      for (ObjectCursor<String> cur : map.keys()) {
        count = map.get(cur.value);
        if (count > max.i) max.set(cur.value, count);
      }

      return max;
    }

    return null;
  }
Beispiel #3
0
  public void add(String key, String value, int count) {
    ObjectIntHashMap<String> map;

    if (containsKey(key)) {
      map = get(key);

      map.put(value, map.get(value) + count);
      map.put(TOTAL, map.get(TOTAL) + count);
    } else {
      map = new ObjectIntHashMap<String>();
      put(key, map);

      map.put(value, count);
      map.put(TOTAL, count);
    }

    i_total += count;
  }