📄 binnode.java
字号:
/**
* This is the node for the BST tree.
* It includes an object field to store the value, and two references to
* store the pointers to the children nodes.
*
* @author Ting Chen 0122070
* @version 1.0 2003/5/30
*/
public class BinNode {
/** Object for this node */
private String element;
/** Pointer to left child */
private BinNode left;
/** Pointer to right child */
private BinNode right;
/**
* The constructor for this class. <p>
* It initializes all the fields to null
*
*/
public BinNode()
{
left = right = null;
}
/**
* The constructor for this class. <p>
* It initializes the fields to the parameters given.
*
* @param val The value for the node.
*/
public BinNode(String val)
{
left = right = null;
element = val;
}
/**
* The constructor for this class. <p>
* It initializes the fields to the parameters given.
*
* @param val The value for the node.
* @param l The left child of the node.
* @param r The right child of the node.
*/
public BinNode(String val, BinNode l, BinNode r)
{
left = l; right = r; element = val;
}
/**
* Return the element value.
*
*/
public String element()
{
return element;
}
/**
* Set the element value and return the set value.
*
* @param v The new value of the node.
*/
public String setElement(String v)
{
return element = v;
}
/**
* Return the left chile node.
*
*/
public BinNode left()
{
return left;
}
/**
* Set the left child node and return the set node.
*
* @param p The new value of the left child node.
*/
public BinNode setLeft(BinNode p)
{
return left = p;
}
/**
* Return the right chile node.
*
*/
public BinNode right()
{
return right;
}
/**
* Set the right child node and return the set node.
*
* @param p The new value of the right child node.
*/
public BinNode setRight(BinNode p)
{
return right = p;
}
/**
* Return true if this is a leaf node.
*/
public boolean isLeaf()
{
return (left == null) && (right == null);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -