本文整理汇总了C#中BinaryTree.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryTree.Delete方法的具体用法?C# BinaryTree.Delete怎么用?C# BinaryTree.Delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryTree
的用法示例。
在下文中一共展示了BinaryTree.Delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteTest
public void DeleteTest()
{
var tree = new BinaryTree<float>();
tree.Add(4.21f);
tree.Add(421);
tree.Add(42);
tree.Add(1);
tree.Add(1000.500f);
tree.Delete(4.21f);
Assert.IsFalse(tree.Contains(4.21f));
Assert.IsTrue(tree.Contains(421));
Assert.IsTrue(tree.Contains(42));
Assert.IsTrue(tree.Contains(1));
tree.Delete(421);
Assert.IsFalse(tree.Contains(421));
Assert.IsTrue(tree.Contains(1));
tree.Delete(1);
Assert.IsFalse(tree.Contains(1));
Assert.IsFalse(tree.Contains(421));
Assert.IsTrue(tree.Contains(42));
tree.Delete(42);
Assert.IsFalse(tree.Contains(42));
Assert.IsTrue(tree.Contains(1000.500f));
tree.Delete(1000.500f);
Assert.IsFalse(tree.Contains(1000.500f));
Assert.IsTrue(tree.IsEmpty());
}
示例2: DeleteWhereOnlyRootExists
public void DeleteWhereOnlyRootExists()
{
var root = new Node(7);
var tree = new BinaryTree(root);
tree.Delete(7);
Assert.AreEqual(String.Empty, tree.ToString());
}
示例3: DeleteTest2
public void DeleteTest2()
{
var tree = new BinaryTree<int>();
tree.Add(4);
tree.Add(1);
tree.Add(3);
tree.Add(2);
tree.Add(5);
tree.Delete(4);
Assert.IsTrue(tree.Contains(3));
}
示例4: Main
/// <summary>
/// Main program method
/// </summary>
/// <param name="args"></param>
private static void Main(string[] args)
{
var tree = new BinaryTree<int>();
tree.Add(5);
tree.Add(3);
tree.Add(6);
tree.Print();
tree.Delete(6);
tree.Print();
Console.WriteLine(tree.Contains(6));
}
示例5: DeleteFromLeftOfRootNodeIsRemoved
public void DeleteFromLeftOfRootNodeIsRemoved()
{
var tree = new BinaryTree(null);
tree.Insert(7);
tree.Insert(1);
tree.Insert(0);
tree.Insert(3);
tree.Insert(2);
tree.Insert(5);
tree.Insert(4);
tree.Insert(6);
tree.Insert(9);
tree.Insert(8);
tree.Insert(10);
tree.Delete(1);
Assert.AreEqual("7,2,0,3,5,4,6,9,8,10", tree.ToString());
}