package pengyifan.counter;

import java.util.TreeMap;

public class TreeCounter<K> extends Counter<K> {

  /**
   * Constructs a new (empty) Counter.
   */
  public TreeCounter() {
    map = new TreeMap<K, MutableInteger>();
    totalCount = 0;
  }

  /**
   * Constructs a new Counter with the contents of the given Counter.
   * 
   * @param counter
   */
  public TreeCounter(Counter<K> counter) {
    this();
    addAll(counter);
  }

  @Override
  public Object clone() {
    return new TreeCounter<K>(this);
  }
}

@@ -21,16 +21,45 @@
 unter;%0A%0A
+import java.util.Comparator;%0A
 import j
@@ -304,140 +304,560 @@
 new 
-Counter with the contents of the given Counter.%0A   * %0A   * @param counter%0A   */%0A  public TreeCounter(Counter%3CK%3E counter) %7B%0A    this(
+(empty) Counter.%0A   */%0A  public TreeCounter(Comparator%3C? super K%3E comparator) %7B%0A    map = new TreeMap%3CK, MutableInteger%3E(comparator);%0A    totalCount = 0;%0A  %7D%0A%0A  /**%0A   * Constructs a new Counter with the contents of the given Counter.%0A   * %0A   * @param counter%0A   */%0A  public TreeCounter(Counter%3CK%3E counter) %7B%0A    this();%0A    addAll(counter);%0A  %7D%0A%0A  /**%0A   * Constructs a new Counter with the contents of the given Counter.%0A   * %0A   * @param counter%0A   */%0A  public TreeCounter(Counter%3CK%3E counter, Comparator%3C? super K%3E comparator) %7B%0A    this(comparator
 );%0A 

add comparator in TreeCounter