本文整理汇总了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);
}
示例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);
}
示例3: SearchingEmptyTreeFails
public void SearchingEmptyTreeFails()
{
var tree = new BinaryTree<int, int>();
tree.Find(1);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}