node.java

来自「基于哈夫曼树的压缩解压程序源代码」· Java 代码 · 共 50 行

JAVA
50
字号
package logical;

import java.io.Serializable;

public class Node implements Serializable {

	private static final long serialVersionUID = 1L;

	long weight; // the weight of the Node

	int name; // the name of the Node, store the value of the Node

	Node lchild, rchild, parent;

	Node() {
		// Initialization
		this.name = -1;
		this.weight = 0;
		this.lchild = null;
		this.rchild = null;
		this.parent = null;
	}

	// get the left child of the Node
	public Node getLeftChild() {
		return this.lchild;
	}

	// get the right child with the given Node
	public Node getRightChild() {
		return this.rchild;
	}

	// get the parent of the Node
	public Node getParent() {
		return this.parent;
	}

	// get the value of the Node
	public int getValue() {
		return this.name;
	}

	// Check out if the Node is a leaf
	public boolean isLeaf() {
		return (this.lchild == null) && (this.rchild == null);
	}

}

⌨️ 快捷键说明

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