public void TestDelete() { Assert.IsFalse(tree.Present(94)); tree.Insert(94); Assert.IsTrue(tree.Present(94)); tree.Delete(94); Assert.IsFalse(tree.Present(94)); }
public void Delete(T val) { if (_enabled && _value.Equals(val)) { _enabled = false; return; } // don't actually delete the value, we still want to be able to use it for traversal if (_value.CompareTo(val) >= 0) { if (_left != null) { _left.Delete(val); } } if (_value.CompareTo(val) < 0) { if (_right != null) { _right.Delete(val); } } }