huffmannode.java

来自「java版的数据结构的完全代码 免费提供了 学习数据结构的请下载」· Java 代码 · 共 30 行

JAVA
30
字号
// Introduced in Chapter 17/** Node in a Huffman tree. */public class HuffmanNode extends BinaryNode<Character>  implements Comparable<HuffmanNode> {  /** Frequency of this letter or set of letters. */  private int count;  /** Create a node with no children. */  public HuffmanNode(char letter, int count) {    super(letter);    this.count = count;  }  /**   * Create a node with two children.  Its count is the sum of   * its children's counts.   */  public HuffmanNode(HuffmanNode left, HuffmanNode right) {    super('?', left, right);    this.count = left.count + right.count;  }  /** The comparison is based on the counts of the nodes. */  public int compareTo(HuffmanNode that) {    return count - that.count;  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?