@Override
  public int remove(int key) {
    int rv = counts.remove(key);
    sumOfCounts -= rv;

    return rv;
  }
  @Override
  public int set(int key, int cnt) {
    int rv = counts.put(key, cnt);
    sumOfCounts = sumOfCounts - rv + cnt;

    return rv;
  }
  private List<PairOfInts> getEntriesSorted(Comparator<PairOfInts> comparator) {
    List<PairOfInts> list = Lists.newArrayList();

    for (MapII.Entry e : counts.entrySet()) {
      list.add(new PairOfInts(e.getKey(), e.getValue()));
    }

    Collections.sort(list, comparator);
    return list;
  }
 @Override
 public double computeLogRelativeFrequency(int k) {
   return Math.log(counts.get(k)) - Math.log(getSumOfCounts());
 }
 @Override
 public double computeRelativeFrequency(int k) {
   return (double) counts.get(k) / getSumOfCounts();
 }
 @Override
 public int get(int key) {
   return counts.get(key);
 }
 @Override
 public boolean contains(int key) {
   return counts.containsKey(key);
 }
 @Override
 public void write(DataOutput out) throws IOException {
   out.writeLong(sumOfCounts);
   counts.write(out);
 }
 @Override
 public void readFields(DataInput in) throws IOException {
   sumOfCounts = in.readLong();
   counts.readFields(in);
 }
 @Override
 public int getNumberOfEvents() {
   return counts.size();
 }
 @Override
 public void clear() {
   counts.clear();
   sumOfCounts = 0;
 }