binarytreenode.java

来自「源程序(包括最初的版本」· Java 代码 · 共 52 行

JAVA
52
字号
package treeandbtreedemo;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: </p> * @author not attributable * @version 1.0 * @version 2.2(2005.7.6)在基础架构中添加了二叉树类,把树和二叉树两种结构分开来做了 */public class BinaryTreeNode{   // datastructures包内可见的数据成员   protected Object element;   protected BinaryTreeNode leftChild;    // 对左子树的引用   protected BinaryTreeNode rightChild;   // 对右子树的引用   // 三个重载的构造方法   public BinaryTreeNode() {}   public BinaryTreeNode(Object theElement)      {element = theElement;}   public BinaryTreeNode(Object theElement,                         BinaryTreeNode theleftChild,                         BinaryTreeNode therightChild)   {       element = theElement;       leftChild = theleftChild;       rightChild = therightChild;   }   // 访问性方法   public BinaryTreeNode getLeftChild() {return leftChild;}   public BinaryTreeNode getRightChild() {return rightChild;}   public Object getElement() {return element;}   // 针对数据成员的变异性方法   public void setLeftChild(BinaryTreeNode theLeftChild)      {leftChild = theLeftChild;}   public void setRightChild(BinaryTreeNode theRightChild)      {rightChild = theRightChild;}   public void setElement(Object theElement)      {element = theElement;}   // 输出数据元素方法   public String toString()     {return element.toString();}}

⌨️ 快捷键说明

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