本文整理汇总了C#中BinarySearchTree.Mirror方法的典型用法代码示例。如果您正苦于以下问题:C# BinarySearchTree.Mirror方法的具体用法?C# BinarySearchTree.Mirror怎么用?C# BinarySearchTree.Mirror使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinarySearchTree
的用法示例。
在下文中一共展示了BinarySearchTree.Mirror方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BinarySearchTreeTests_Random_Mirror
public void BinarySearchTreeTests_Random_Mirror()
{
Random r = new Random();
int n = r.Next(1000000) + 1;
IBinarySearchTree<int, string> tree = new BinarySearchTree<int, string>();
for (int i = 0; i < n; i++)
{
int key = r.Next(int.MaxValue);
tree.Insert(key, string.Empty);
}
var expectedOrder = tree.TraverseInOrder().Reverse();
tree.Mirror();
var actualOrder = tree.TraverseInOrder().ToList();
Assert.IsTrue(expectedOrder.Except(actualOrder).Count() == 0);
Assert.IsTrue(actualOrder.Except(expectedOrder).Count() == 0);
}
示例2: BinarySearchTreeTests_Mirror
public void BinarySearchTreeTests_Mirror()
{
IBinarySearchTree<int, string> tree = new BinarySearchTree<int, string>();
tree.Insert(10, "John");
tree.Insert(5, "Clark");
tree.Insert(13, "Pitty");
tree.Insert(17, "Lilly");
tree.Insert(8, "Jack");
tree.Insert(0, "Lui");
tree.Insert(16, "Petr");
var expectedOrder = tree.TraverseInOrder().Reverse();
tree.Mirror();
var actualOrder = tree.TraverseInOrder().ToList();
Assert.IsTrue(expectedOrder.Except(actualOrder).Count() == 0);
Assert.IsTrue(actualOrder.Except(expectedOrder).Count() == 0);
}