本文整理汇总了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));
}