當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。