⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 btnode.java

📁 用java实现的LinkedList二叉树
💻 JAVA
字号:
/*
 * Created on 2005-10-27
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package linkedBinaryTree;

/**
 * @author dieks
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class BTNode implements Position {
    private BTNode parent, left, right;
    private Object element;

    public BTNode(BTNode _parent, BTNode _left, BTNode _right, Object _element) {
        parent = _parent;
        left = _left;
        right = _right;
        element = _element;
    }
    
    public Object element() throws InvalidPositionException {
        if (((left == null)  && (right != null)) || (left != null) && (right == null)){
            throw new InvalidPositionException("Position not in a tree");
        }
        return element;
	}
    
    public void setElement(Object e){
    	element = e;
    }

    public void setLeft(BTNode _left) {
        left = _left;
    }
    
    public void setRight(BTNode _right) {
        right = _right;
    }
    
    public void setParent(BTNode _parent){
    	parent = _parent;
    }
    
    public BTNode getLeft() {
    	return this.left;
    }
    
    public BTNode getRight() {
    	return this.right;
    }
    
    public BTNode getParent() {
    	return this.parent;
    }
}

⌨️ 快捷键说明

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