/// <summary> /// Removes the left child. /// </summary> public virtual void RemoveRight() { rightSubtree = null; }
/// <summary> /// Removes the left child. /// </summary> public virtual void RemoveLeft() { leftSubtree = null; }
/// <summary> /// Initializes a new instance of the <see cref="BinaryTree<T>"/> class. /// </summary> /// <param name="data">The data contained in this node.</param> /// <param name="left">The left subtree.</param> /// <param name="right">The right subtree.</param> public BinaryTree(T data, BinaryTree <T> left, BinaryTree <T> right) { leftSubtree = left; rightSubtree = right; this.data = data; }
/// <summary> /// Clears all the objects in this instance. /// </summary> public void Clear() { leftSubtree = null; rightSubtree = null; }
/// <summary> /// Removes all items from the <see cref="T:System.Collections.Generic.ICollection`1"></see>. /// </summary> /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"></see> is read-only. </exception> public void Clear() { tree = null; count = 0; }
/// <summary> /// Finds the min node. /// </summary> /// <param name="startNode">The start node.</param> /// <param name="parent">The parent of the node found.</param> /// <returns>The minimum node underneath the node specified. If the node specified is a leaf node, it is returned.</returns> private BinaryTree <Association <TKey, TValue> > FindMinNode(BinaryTree <Association <TKey, TValue> > startNode, out BinaryTree <Association <TKey, TValue> > parent) { #region Asserts Debug.Assert(startNode != null); #endregion BinaryTree <Association <TKey, TValue> > searchNode = startNode; parent = null; while (searchNode.Left != null) { parent = searchNode; searchNode = searchNode.Left; } return(searchNode); }