当前位置: 首页>>代码示例>>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;未经允许,请勿转载。