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


C# BinaryTree.Find方法代碼示例

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


在下文中一共展示了BinaryTree.Find方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SearchingForNonExistantKeyFails

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

            var a = tree.Add(4, "a");
            var b = tree.Add(3, "b");
            var c = tree.Add(5, "c");
            var d = tree.Add(2, "d");
            var e = tree.Add(6, "e");
            var f = tree.Add(-1, "f");
            var g = tree.Add(10, "g");
            var h = tree.Add(44, "h");

            tree.Find(100);
        }
開發者ID:xoxota99,項目名稱:HandyCollections,代碼行數:15,代碼來源:BinaryTreeTest.cs

示例2: Find

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

            var a = tree.Add(4, "a");
            var b = tree.Add(3, "b");
            var c = tree.Add(5, "c");
            var d = tree.Add(2, "d");
            var e = tree.Add(6, "e");
            var f = tree.Add(-1, "f");
            var g = tree.Add(10, "g");
            var h = tree.Add(44, "h");

            Assert.IsTrue(tree.Find(4) == a);
            Assert.IsTrue(tree.Find(3) == b);
            Assert.IsTrue(tree.Find(5) == c);
            Assert.IsTrue(tree.Find(2) == d);
            Assert.IsTrue(tree.Find(6) == e);
            Assert.IsTrue(tree.Find(-1) == f);
            Assert.IsTrue(tree.Find(10) == g);
            Assert.IsTrue(tree.Find(44) == h);
        }
開發者ID:xoxota99,項目名稱:HandyCollections,代碼行數:22,代碼來源:BinaryTreeTest.cs

示例3: SearchingEmptyTreeFails

 public void SearchingEmptyTreeFails()
 {
     var tree = new BinaryTree<int, int>();
     tree.Find(1);
 }
開發者ID:xoxota99,項目名稱:HandyCollections,代碼行數:5,代碼來源:BinaryTreeTest.cs

示例4: FindReturnsTrueWhenValueIsOnSecondLevel

        public void FindReturnsTrueWhenValueIsOnSecondLevel()
        {
            var root = new Node(7);
            root.Left = new Node(1);
            root.Right = new Node(9);

            var tree = new BinaryTree(root);
            var result = tree.Find(9);

            Assert.AreEqual(9, result.Value);
        }
開發者ID:kawillia,項目名稱:Trees,代碼行數:11,代碼來源:BinaryTreeTests.cs

示例5: FindReturnsTrueWhenValueIsOnRightOfThirdLevelWhenLeftIsNull

        public void FindReturnsTrueWhenValueIsOnRightOfThirdLevelWhenLeftIsNull()
        {
            var root = new Node(7);
            root.Left = new Node(1);
            root.Right = new Node(9);
            root.Left.Right = new Node(3);

            var tree = new BinaryTree(root);
            var result = tree.Find(3);

            Assert.AreEqual(3, result.Value);
        }
開發者ID:kawillia,項目名稱:Trees,代碼行數:12,代碼來源:BinaryTreeTests.cs

示例6: FindReturnsTrueWhenValueIsOnFourthLevel

        public void FindReturnsTrueWhenValueIsOnFourthLevel()
        {
            var root = new Node(7);
            root.Left = new Node(1);
            root.Right = new Node(9);
            root.Left.Left = new Node(0);
            root.Left.Right = new Node(3);
            root.Left.Right.Left = new Node(2);
            root.Left.Right.Right = new Node(5);
            root.Left.Right.Right.Left = new Node(4);
            root.Left.Right.Right.Right = new Node(6);

            var tree = new BinaryTree(root);
            var result = tree.Find(4);

            Assert.AreEqual(4, result.Value);
        }
開發者ID:kawillia,項目名稱:Trees,代碼行數:17,代碼來源:BinaryTreeTests.cs

示例7: FindReturnsNullWhenValueIsNotInTree

        public void FindReturnsNullWhenValueIsNotInTree()
        {
            var root = new Node(7);
            root.Left = new Node(1);
            root.Right = new Node(9);
            root.Left.Left = new Node(0);
            root.Left.Right = new Node(3);
            root.Left.Right.Left = new Node(2);
            root.Left.Right.Right = new Node(5);
            root.Left.Right.Right.Left = new Node(4);
            root.Left.Right.Right.Right = new Node(6);

            var tree = new BinaryTree(root);

            Assert.IsNull(tree.Find(42));
        }
開發者ID:kawillia,項目名稱:Trees,代碼行數:16,代碼來源:BinaryTreeTests.cs

示例8: FindReturnNodeWhenValueIsRoot

        public void FindReturnNodeWhenValueIsRoot()
        {
            var root = new Node(7);
            var tree = new BinaryTree(root);
            var result = tree.Find(7);

            Assert.AreEqual(7, result.Value);
        }
開發者ID:kawillia,項目名稱:Trees,代碼行數:8,代碼來源:BinaryTreeTests.cs


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