當前位置: 首頁>>代碼示例>>C#>>正文


C# BinaryTree.Add方法代碼示例

本文整理匯總了C#中BinaryTree.Add方法的典型用法代碼示例。如果您正苦於以下問題:C# BinaryTree.Add方法的具體用法?C# BinaryTree.Add怎麽用?C# BinaryTree.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BinaryTree的用法示例。


在下文中一共展示了BinaryTree.Add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: Interface

        public void Interface()
        {
            var rootBinaryTree = new BinaryTree<int>(5);

            var child1 = new BinaryTree<int>(2);
            var child2 = new BinaryTree<int>(3);

            rootBinaryTree.Add(child1);
            rootBinaryTree.Add(child2);

            var child4 = new BinaryTree<int>(9);
            var child5 = new BinaryTree<int>(12);
            var child6 = new BinaryTree<int>(13);

            child1.Add(child4);
            child1.Add(child5);
            child2.Add(child6);

            ITree<int> tree = rootBinaryTree;
            Assert.AreEqual(tree.FindNode(target => target == 2), child1);

            Assert.AreEqual(tree.FindNode(target => target == 9), child4);

            Assert.AreEqual(tree.FindNode(target => target == 13), child6
                );

            Assert.AreEqual(tree.FindNode(target => target == 57), null);
        }
開發者ID:GTuritto,項目名稱:ngenerics,代碼行數:28,代碼來源:FindNode.cs

示例3: Simple

        public void Simple()
        {
            var binaryTree = new BinaryTree<int>(5);

            Assert.AreEqual(binaryTree.Count, 0);
            Assert.AreEqual(binaryTree.Degree, 0);
            Assert.AreEqual(binaryTree.Data, 5);

            binaryTree.Add(3);

            Assert.AreEqual(binaryTree.Count, 1);
            Assert.AreEqual(binaryTree.Degree, 1);
            Assert.AreEqual(binaryTree.Data, 5);

            Assert.AreEqual(binaryTree.Left.Data, 3);
            Assert.IsNull(binaryTree.Right);

            binaryTree.Add(4);

            Assert.AreEqual(binaryTree.Count, 2);
            Assert.AreEqual(binaryTree.Degree, 2);
            Assert.AreEqual(binaryTree.Data, 5);

            Assert.AreEqual(binaryTree.Left.Data, 3);
            Assert.AreEqual(binaryTree.Right.Data, 4);
        }
開發者ID:havok,項目名稱:ngenerics,代碼行數:26,代碼來源:Add.cs

示例4: BeginTestMethod

 public void BeginTestMethod()
 {
     target = new BinaryTree<String>();
     target.Add(3, "three");
     target.Add(2, "two");
     target.Add(7, "seven");
 }
開發者ID:hirotk,項目名稱:Algorithm,代碼行數:7,代碼來源:BinarySearchTreeTest.cs

示例5: Simple

        public void Simple()
        {
            var binaryTree = new BinaryTree<int>(5);

            var child1 = new BinaryTree<int>(2);
            var child2 = new BinaryTree<int>(3);

            binaryTree.Add(child1);
            binaryTree.Add(child2);

            var child4 = new BinaryTree<int>(9);
            var child5 = new BinaryTree<int>(12);
            var child6 = new BinaryTree<int>(13);

            child1.Add(child4);
            child1.Add(child5);
            child2.Add(child6);

            Assert.AreEqual(binaryTree.FindNode(target => target == 2), child1);

            Assert.AreEqual(binaryTree.FindNode(target => target == 9), child4);

            Assert.AreEqual(binaryTree.FindNode(target => target == 13), child6);

            Assert.AreEqual(binaryTree.FindNode(target => target == 57), null);
        }
開發者ID:GTuritto,項目名稱:ngenerics,代碼行數:26,代碼來源:FindNode.cs

示例6: DuplicateKeysNotAllowed

        public void DuplicateKeysNotAllowed()
        {
            BinaryTree<int, string> tree = new BinaryTree<int, string>();

            tree.Add(3, "a");
            tree.Add(3, "a");
        }
開發者ID:xoxota99,項目名稱:HandyCollections,代碼行數:7,代碼來源:BinaryTreeTest.cs

示例7: Add_ToFullIntTree_ExpandsTree

 public void Add_ToFullIntTree_ExpandsTree()
 {
     BinaryTree<int> tree = new BinaryTree<int>(new int[] { 54, 25, 316, 4, 55, 6, });
     tree.Add(11);
     tree.Add(41);
     tree.Add(111);
     Assert.AreEqual(9, tree.Count);
 }
開發者ID:helenakolodko,項目名稱:DataStructures,代碼行數:8,代碼來源:BinaryTreeTest.cs

示例8: IndexTest

 public void IndexTest()
 {
     var d = new BinaryTree<int, bool>();
     d.Add(10, true);
     d.Add(20, true);
     d.Add(30, true);
     d.Add(40, true);
     d.Add(25, true);
     Assert.AreEqual(2, d.IndexOfKey(25));
 }
開發者ID:sam0737,項目名稱:hellosam.net.collections,代碼行數:10,代碼來源:BinaryTreeTest.cs

示例9: CountTest

 public void CountTest()
 {
     var tree = new BinaryTree<int>();
     tree.Add(new BinaryTreeNode<int>(1));
     Assert.AreEqual(1, tree.Count);
     tree.Add(new BinaryTreeNode<int>(2));
     Assert.AreEqual(2, tree.Count);
     tree.Add(new BinaryTreeNode<int>(0));
     Assert.AreEqual(3, tree.Count);
 }
開發者ID:codenetio,項目名稱:DataStructures.BinaryTree,代碼行數:10,代碼來源:BinaryTreeTests.cs

示例10: BinaryTreeAddLeaf

 public void BinaryTreeAddLeaf()
 {
     var tree = new BinaryTree<int>();
     tree.Add(4);
     tree.Add(1);
     tree.Add(10);
     tree.ShouldContain(1);
     tree.ShouldContain(4);
     tree.ShouldContain(10);
 }
開發者ID:RazvanHidan,項目名稱:Probleme,代碼行數:10,代碼來源:BinaryTreeTest.cs

示例11: Creation

 public void Creation()
 {
     BinaryTree<int> Tree = new BinaryTree<int>();
     Tree.Add(1);
     Tree.Add(2);
     Tree.Add(0);
     Tree.Add(-1);
     Assert.Equal(-1, Tree.MinValue);
     Assert.Equal(2, Tree.MaxValue);
 }
開發者ID:gwilkinson,項目名稱:Craig-s-Utility-Library,代碼行數:10,代碼來源:BTree.cs

示例12: BinaryTree_Test

        public void BinaryTree_Test()
        {
            BinaryTree<int> tree = new BinaryTree<int>();
            tree.Add(5);
            tree.Add(10);
            tree.Add(80);
            tree.Add(5);
            tree.Add(2);

            Assert.AreEqual(4, tree.Count);
        }
開發者ID:AnnZanevskaya,項目名稱:ASP.NET.Zanevskaya.FinalDay,代碼行數:11,代碼來源:BinaryTreeTest.cs

示例13: 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

示例14: 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

示例15: BinaryTreeTest_Add

        public void BinaryTreeTest_Add()
        {
            BinaryTree<int> tree = new BinaryTree<int>();

            tree.Add(6);
            tree.Add(3);
            tree.Add(9);
            tree.Add(1);
            tree.Add(4);

            int i = 0;
        }
開發者ID:AlexanderChechet,項目名稱:ASP.NET.AlexanderChechet.Test,代碼行數:12,代碼來源:BinaryTreeTest.cs


注:本文中的BinaryTree.Add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。