当前位置: 首页>>代码示例>>C#>>正文


C# BinaryTree.Delete方法代码示例

本文整理汇总了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());
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:27,代码来源:BinaryTreeTests.cs

示例2: DeleteWhereOnlyRootExists

        public void DeleteWhereOnlyRootExists()
        {
            var root = new Node(7);
            var tree = new BinaryTree(root);
            tree.Delete(7);

            Assert.AreEqual(String.Empty, tree.ToString());
        }
开发者ID:kawillia,项目名称:Trees,代码行数:8,代码来源:BinaryTreeTests.cs

示例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));
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:11,代码来源:BinaryTreeTests.cs

示例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));
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:15,代码来源:Program.cs

示例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());
        }
开发者ID:kawillia,项目名称:Trees,代码行数:18,代码来源:BinaryTreeTests.cs


注:本文中的BinaryTree.Delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。