本文整理匯總了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);
}
示例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));
}
示例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);
}
示例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);
}
示例5: FindNodeNotInBstTest
public void FindNodeNotInBstTest()
{
BinarySearchTree<int> bst = new BinarySearchTree<int> {10, 5, 15};
Assert.IsNull(bst.FindNode(34));
}