package lesson4; /** * 哈弗曼节点 * */ public class hfmNode implements Comparable<hfmNode>{ public int data; public int times; public hfmNode lChild; public hfmNode rChild; public hfmNode(int data,int times){ this.data=data; this.times=times; } /** * 自定义自然比较方法 */ public int compareTo(hfmNode o) { // System.out.println("排序了~"); if(times-o.times>0){ return 1; }else return 0; } }