Source of 24.7.java


  1: private void privateSetTree(T rootData, BinaryTree<T> leftTree, BinaryTree<T> rightTree)
  2: {
  3:    root = new BinaryNode<>(rootData);
  4: 
  5:    if ((leftTree != null) && !leftTree.isEmpty())
  6:       root.setLeftChild(leftTree.root);
  7: 
  8:    if ((rightTree != null) && !rightTree.isEmpty())
  9:    {
 10:       if (rightTree != leftTree)
 11:          root.setRightChild(rightTree.root);
 12:       else
 13:          root.setRightChild(rightTree.root.copy());
 14:    } // end if
 15: 
 16:    if ((leftTree != null) && (leftTree != this))
 17:       leftTree.clear();
 18: 
 19:    if ((rightTree != null) && (rightTree != this))
 20:       rightTree.clear();
 21: } // end privateSetTree
 22: // Version 4.0
 23: