本文整理汇总了C#中BinarySearchTree.AddElement方法的典型用法代码示例。如果您正苦于以下问题:C# BinarySearchTree.AddElement方法的具体用法?C# BinarySearchTree.AddElement怎么用?C# BinarySearchTree.AddElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinarySearchTree
的用法示例。
在下文中一共展示了BinarySearchTree.AddElement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
BinarySearchTree<string> testSubject = new BinarySearchTree<string>("Dani");
Console.WriteLine(testSubject.Root.NodeValue);
testSubject.AddElement("Ivan");
testSubject.AddElement("Petar");
testSubject.AddElement("Asen");
testSubject.AddElement("Eve");
TreeNode wantedItem = testSubject.SearchElement("Ivan");
Console.WriteLine(wantedItem);
//Deleting item proved to be too hard for me. IEnumerable<t> implementation too.
}
示例2: Main
static void Main()
{
BinarySearchTree<int> tree = new BinarySearchTree<int>();
tree.AddElement(13);
tree.AddElement(17);
tree.AddElement(101);
tree.AddElement(44);
tree.AddElement(9);
tree.AddElement(11);
BinarySearchTree<int> tree2 = (BinarySearchTree<int>)tree.Clone();
//tree2.AddElement(45);
//tree2.AddElement(99);
Console.WriteLine("Tree: " + tree.ToString());
Console.WriteLine("Tree2: " + tree2.ToString());
Console.WriteLine("Tree equals Tree2: " + tree.Equals(tree2));
Console.WriteLine("Tree == Tree2: " + (tree == tree2));
Console.WriteLine("Tree != Tree2: " + (tree != tree2));
Console.Write("Traverse with foreach: ");
foreach (TreeNode<int> item in tree)
Console.Write(item.Value + " ");
Console.WriteLine();
Console.WriteLine("Tree hash: {0}", tree.GetHashCode());
Console.WriteLine("Tree2 hash: {0}", tree2.GetHashCode());
}
示例3: Main
static void Main()
{
BinarySearchTree<int> tree1 = new BinarySearchTree<int>(10);
tree1.AddElement(5);
tree1.AddElement(15);
tree1.AddElement(5);
tree1.AddElement(15);
tree1.AddElement(5);
tree1.AddElement(15);
tree1.PrintTree();
}