本文整理汇总了C#中BinaryTreeNode.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryTreeNode.Insert方法的具体用法?C# BinaryTreeNode.Insert怎么用?C# BinaryTreeNode.Insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryTreeNode
的用法示例。
在下文中一共展示了BinaryTreeNode.Insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: testNotInTree
public void testNotInTree() {
BinaryTreeNode<Int32> root = new BinaryTreeNode<Int32>(2);
root.Insert(5);
root.Insert(1);
root.Insert(16);
bool exceptionCaught_v1 = false;
bool exceptionCaught_v2 = false;
bool exceptionCaught_v3 = false;
#pragma warning disable 168
try {
Assert.AreEqual(eu.sig.training.ch03.binarytree.v1.BinaryTreeSearch.CalculateDepth(root, 17), 0);
} catch (TreeException e) {
exceptionCaught_v1 = true;
}
try {
Assert.AreEqual(eu.sig.training.ch03.binarytree.v2.BinaryTreeSearch
.CalculateDepth(root, 17), 0);
} catch (TreeException e) {
exceptionCaught_v2 = true;
}
try {
Assert.AreEqual(eu.sig.training.ch03.binarytree.v3.BinaryTreeSearch
.CalculateDepth(root, 17), 0);
} catch (TreeException e) {
exceptionCaught_v3 = true;
}
Assert.IsTrue(exceptionCaught_v1);
Assert.IsTrue(exceptionCaught_v2);
Assert.IsTrue(exceptionCaught_v3);
#pragma warning restore 168
}
示例2: testSimpleTree
public void testSimpleTree() {
BinaryTreeNode<Int32> root = new BinaryTreeNode<Int32>(5);
root.Insert(3);
root.Insert(10);
root.Insert(12);
Assert.AreEqual(eu.sig.training.ch03.binarytree.v1.BinaryTreeSearch.CalculateDepth(root, 12), 2);
Assert.AreEqual(eu.sig.training.ch03.binarytree.v2.BinaryTreeSearch.CalculateDepth(root, 12), 2);
Assert.AreEqual(eu.sig.training.ch03.binarytree.v3.BinaryTreeSearch.CalculateDepth(root, 12), 2);
}
示例3: testDepth0
public void testDepth0() {
BinaryTreeNode<Int32> root = new BinaryTreeNode<Int32>(2);
root.Insert(5);
root.Insert(1);
root.Insert(16);
Assert.AreEqual(eu.sig.training.ch03.binarytree.v1.BinaryTreeSearch.CalculateDepth(root, 2), 0);
Assert.AreEqual(eu.sig.training.ch03.binarytree.v2.BinaryTreeSearch.CalculateDepth(root, 2), 0);
Assert.AreEqual(eu.sig.training.ch03.binarytree.v3.BinaryTreeSearch.CalculateDepth(root, 2), 0);
}