本文整理汇总了C#中BinaryTree.Exists方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryTree.Exists方法的具体用法?C# BinaryTree.Exists怎么用?C# BinaryTree.Exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryTree
的用法示例。
在下文中一共展示了BinaryTree.Exists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExistsReturnsTrueWhenValueIsOnFourthLevel
public void ExistsReturnsTrueWhenValueIsOnFourthLevel()
{
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.IsTrue(tree.Exists(4));
}
示例2: ExistsReturnsFalseWhenValueIsNotInTree
public void ExistsReturnsFalseWhenValueIsNotInTree()
{
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.IsFalse(tree.Exists(42));
}
示例3: ExistsReturnsTrueWhenValueIsOnRightOfThirdLevelWhenLeftIsNull
public void ExistsReturnsTrueWhenValueIsOnRightOfThirdLevelWhenLeftIsNull()
{
var root = new Node(7);
root.Left = new Node(1);
root.Right = new Node(9);
root.Left.Right = new Node(10);
var tree = new BinaryTree(root);
Assert.IsTrue(tree.Exists(10));
}
示例4: ExistsReturnsFalseWhenTreeHasNoRoot
public void ExistsReturnsFalseWhenTreeHasNoRoot()
{
var tree = new BinaryTree(null);
Assert.IsFalse(tree.Exists(1));
}
示例5: ExistsReturnsTrueWhenValueIsRoot
public void ExistsReturnsTrueWhenValueIsRoot()
{
var root = new Node(7);
var tree = new BinaryTree(root);
Assert.IsTrue(tree.Exists(7));
}
示例6: ExistsReturnsTrueWhenValueIsOnSecondLevel
public void ExistsReturnsTrueWhenValueIsOnSecondLevel()
{
var root = new Node(7);
root.Left = new Node(1);
root.Right = new Node(9);
var tree = new BinaryTree(root);
Assert.IsTrue(tree.Exists(9));
}