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


C# BinarySearchTree.FindNode方法代碼示例

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


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

示例1: RemoveNodeWithBothSubtreesTest

        public void RemoveNodeWithBothSubtreesTest([PexAssumeUnderTest]HashSet<int> setelem, int position)
        {
            List<int> elements = new List<int>(setelem);
            PexAssume.IsTrue(position >= 0 && position < elements.Count);
            PexAssume.IsTrue(elements.Count > 0);

            BinarySearchTree<int> bst = new BinarySearchTree<int>(elements);

            int targetElement = elements[position];
            PexAssert.IsTrue(bst.Remove(targetElement));
            elements.Remove(targetElement);

            if(elements.Contains(targetElement)) //Can happen when there are duplicate elements in the list
                PexAssert.IsNotNull(bst.FindNode(targetElement));
            else
                PexAssert.IsNull(bst.FindNode(targetElement));

            //Assert.AreEqual(19, bst.Root.Left.Value); //Cannot be generalized
            PexAssert.AreEqual(elements.Count, bst.Count);
        }
開發者ID:taoxiease,項目名稱:asegrp,代碼行數:20,代碼來源:BinarySearchTreeTest.cs

示例2: FindNodeValidLeftChildTest

        public void FindNodeValidLeftChildTest([PexAssumeUnderTest]List<int> elements, int position, int notExistingElement)
        {
            PexAssume.IsTrue(position >= 0 && position < elements.Count);
            PexAssume.IsFalse(elements.Contains(notExistingElement));
            BinarySearchTree<int> bst = new BinarySearchTree<int>(elements);

            PexAssert.IsNotNull(bst.FindNode(elements[position]));
            PexAssert.AreEqual(elements[position], bst.FindNode(elements[position]).Value);
            PexAssume.IsNull(bst.FindNode(notExistingElement));
        }
開發者ID:taoxiease,項目名稱:asegrp,代碼行數:10,代碼來源:BinarySearchTreeTest.cs

示例3: FindNodeValidRightChildTest

        public void FindNodeValidRightChildTest()
        {
            BinarySearchTree<int> bst = new BinarySearchTree<int> {10, 5, 14};

            Assert.IsNotNull(bst.FindNode(14));
            Assert.AreEqual(14, bst.FindNode(14).Value);
        }
開發者ID:taoxiease,項目名稱:asegrp,代碼行數:7,代碼來源:BinarySearchTreeTest.cs

示例4: RemoveNodeWithBothSubtreesTest

        public void RemoveNodeWithBothSubtreesTest()
        {
            BinarySearchTree<int> bst = new BinarySearchTree<int> {33, 21, 17, 24, 19, 14, 50, 49};

            Assert.IsTrue(bst.Remove(21));
            Assert.IsNull(bst.FindNode(21));
            Assert.AreEqual(19, bst.Root.Left.Value);
            Assert.AreEqual(7, bst.Count);
        }
開發者ID:taoxiease,項目名稱:asegrp,代碼行數:9,代碼來源:BinarySearchTreeTest.cs

示例5: FindNodeNotInBstTest

        public void FindNodeNotInBstTest()
        {
            BinarySearchTree<int> bst = new BinarySearchTree<int> {10, 5, 15};

            Assert.IsNull(bst.FindNode(34));
        }
開發者ID:taoxiease,項目名稱:asegrp,代碼行數:6,代碼來源:BinarySearchTreeTest.cs


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