private void AddTo(_001_TreeNode.BineryTreeNode <T> node, T value) { if (node.CompareTo(value) > 0) { if (node.Left == null) { node.Left = new _001_TreeNode.BineryTreeNode <T>(value); } else { AddTo(node.Left, value); } } else { if (node.Rigth == null) { node.Rigth = new _001_TreeNode.BineryTreeNode <T>(value); } else { AddTo(node.Rigth, value); } } }
//Find private _001_TreeNode.BineryTreeNode <T> FindWithParent(T value, out _001_TreeNode.BineryTreeNode <T> parent) { _001_TreeNode.BineryTreeNode <T> current = _head; parent = null; while (current != null) { int result = current.CompareTo(value); if (result > 0) { parent = current; current = current.Left; } else if (result < 0) { parent = current; current = current.Rigth; } else { break; } } return(current); }