当前位置: 首页>>代码示例>>C#>>正文


C# BinarySearchTree.AddElement方法代码示例

本文整理汇总了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.
        }
开发者ID:VDGone,项目名称:TelerikAcademy-2,代码行数:14,代码来源:Test.cs

示例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());
        }
开发者ID:Rokata,项目名称:TelerikAcademy,代码行数:29,代码来源:TreeDataStructure.cs

示例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();
        }
开发者ID:purlantov,项目名称:TelerikAcademy-4,代码行数:13,代码来源:BinarySearchTreeTesting.cs


注:本文中的BinarySearchTree.AddElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。