//默认构造函数,按照key的自然顺序排列
// 如果key是自定义类,必须实现Comparable接口
public TreeMap() {
comparator = null;
}
//传递Comparator具体实现,按照该实现规则进行排序
public TreeMap(Comparator<? super K> comparator) {
this.comparator = comparator;
}
public TreeMap(Map<? extends K, ? extends V> m) {
comparator = null;
putAll(m);
}
public TreeMap(SortedMap<K, ? extends V> m) {
comparator = m.comparator();
try {
buildFromSorted(m.size(), m.entrySet().iterator(), null, null);
} catch (java.io.IOException cannotHappen) {
} catch (ClassNotFoundException cannotHappen) {
}
}