/// <summary> /// Join an sub-CART tree this . /// </summary> /// <param name="isLeft">Is a left child .</param> /// <param name="idx">Node index .</param> /// <param name="subRoot">New child node .</param> public void JoinSubTree(bool isLeft, ref int idx, CartNode subRoot) { subRoot.Parent = this; subRoot.Index = idx; if (isLeft) { LeftChild = subRoot; subRoot.ParentIndex = Index; } else { RightChild = subRoot; subRoot.ParentIndex = -Index; } if (subRoot.LeftChild != null) { idx++; subRoot.JoinSubTree(true, ref idx, subRoot.LeftChild); } if (subRoot.RightChild != null) { idx++; subRoot.JoinSubTree(false, ref idx, subRoot.RightChild); } }