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