treenode.java
来自「源程序(包括最初的版本」· Java 代码 · 共 55 行
JAVA
55 行
package treeandbtreedemo;/** * <p>Title: 树节点</p> * <p>Description: 把二叉树与树整合在一起,无论是二叉树还是树,都改成了孩子兄弟链表的形式, * 故二叉树所画出的图形式样也会有所变化。 * 包括节点元素,左小孩,右兄弟</p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: </p> * @author not liuli * @version 1.1(2005.6.29) * @version 2.0(2005.7.5)加入图形界面 * @version 2.1(2005.7.5)初步加入动画和线程,产生节点的遍历动画效果 * @version 2.2(2005.7.6)在基础架构中添加了二叉树类,把树和二叉树两种结构分开来做了 */public class TreeNode { protected Object element; protected TreeNode firstChild;//左小孩 protected TreeNode nextSibling;//右兄弟 //构造方法 public TreeNode() {} public TreeNode(Object theElement) { element=theElement; } public TreeNode(Object theElement,TreeNode theFirstChild,TreeNode theNextSibling){ element=theElement; firstChild=theFirstChild; nextSibling=theNextSibling; } // 访问性方法 public TreeNode getFirstChild() {return firstChild;} public TreeNode getNextSibling() {return nextSibling;} public Object getElement() {return element;} // 针对数据成员的变异性方法 public void setLeftChild(TreeNode theFirstChild){ firstChild=theFirstChild; } public void setRightChild(TreeNode theNextSibling){ nextSibling=theNextSibling; } public void setElement(Object theElement){ element = theElement; } // 输出数据元素方法 public String toString() { return element.toString(); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?