當前位置: 首頁>>代碼示例>>C#>>正文


C# BinarySearchTree.ToArray方法代碼示例

本文整理匯總了C#中BinarySearchTree.ToArray方法的典型用法代碼示例。如果您正苦於以下問題:C# BinarySearchTree.ToArray方法的具體用法?C# BinarySearchTree.ToArray怎麽用?C# BinarySearchTree.ToArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BinarySearchTree的用法示例。


在下文中一共展示了BinarySearchTree.ToArray方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ToArrayTest

 public void ToArrayTest([PexAssumeUnderTest]int[] elements)
 {
     BinarySearchTree<int> bst = new BinarySearchTree<int>(elements);
     int[] actual = bst.ToArray();
     PexObserve.ValueForViewing<int[]>("BinarySearchTree Output", actual);
 }
開發者ID:taoxiease,項目名稱:asegrp,代碼行數:6,代碼來源:BinarySearchTreeTest.cs

示例2: RemoveNodeWithLeftSubtreeOnlyChildGreaterThanOrEqualToParentTest

        public void RemoveNodeWithLeftSubtreeOnlyChildGreaterThanOrEqualToParentTest([PexAssumeUnderTest]int[] elements, int position)
        {
            PexAssume.IsTrue(position >= 0 && position < elements.Length);
            BinarySearchTree<int> bst = new BinarySearchTree<int>(elements);

            PexAssert.IsTrue(bst.Remove(elements[position]));
            PexObserve.ValueForViewing<int[]>("Binary Search Contents", bst.ToArray());
            //Assert.AreEqual(61, bst.Root.Right.Right.Right.Value); //Cannot be generalized
            //Assert.AreEqual(9, bst.Count);
        }
開發者ID:taoxiease,項目名稱:asegrp,代碼行數:10,代碼來源:BinarySearchTreeTest.cs

示例3: InsertTest

        public void InsertTest([PexAssumeUnderTest]int[] newElements)
        {
            BinarySearchTree<int> bst = new BinarySearchTree<int>(newElements);

            PexAssert.AreEqual(newElements.Length, bst.Count);
            PexAssert.IsNotNull(bst.GetEnumerator());
            PexAssert.IsNotNull(bst.GetPostorderEnumerator());
            PexAssert.IsNotNull(bst.GetInorderEnumerator());
            PexAssert.IsNotNull(bst.GetBreadthFirstEnumerator());
            PexObserve.ValueForViewing<int[]>("newElements", newElements);
            PexObserve.ValueForViewing<int[]>("Constructed tree", bst.ToArray());
        }
開發者ID:taoxiease,項目名稱:asegrp,代碼行數:12,代碼來源:BinarySearchTreeTest.cs

示例4: ToArrayTest

        public void ToArrayTest()
        {
            BinarySearchTree<int> bst = new BinarySearchTree<int> {12, 8, 6, 11, 42};

            int[] actual = bst.ToArray();
            int[] expected = {12, 8, 42, 6, 11};

            CollectionAssert.AreEqual(expected, actual);
        }
開發者ID:taoxiease,項目名稱:asegrp,代碼行數:9,代碼來源:BinarySearchTreeTest.cs

示例5: ToArrayNoItemsInBstTest

        public void ToArrayNoItemsInBstTest()
        {
            BinarySearchTree<int> bst = new BinarySearchTree<int>();

            int[] actual = bst.ToArray();

            Assert.AreEqual(0, actual.Length);
        }
開發者ID:taoxiease,項目名稱:asegrp,代碼行數:8,代碼來源:BinarySearchTreeTest.cs

示例6: Main


//.........這裏部分代碼省略.........
        //list.Insert(22, index);
        //Console.WriteLine("New List: " + list.ToString());
        //Console.WriteLine("\nThe COUNT Method");
        //Console.WriteLine("The the count of this list is: " + list.Count);
        //Console.WriteLine("\nThe Get Method");
        //Console.WriteLine("What is at index " + index + ": " + list.Get(index));
        //Console.WriteLine("\nThe REMOVEAT Method");
        //Console.WriteLine("What is at index " + (list.Count - 1) + ": " + list.Get((list.Count - 1)));
        //Console.WriteLine("I am removing the element at index " + (list.Count - 1) + ": " + list.RemoveAt((list.Count - 1)));
        //Console.WriteLine("New List: " + list.ToString());
        //Console.WriteLine("\nThe COUNT Method");
        //Console.WriteLine("The the count of this list is: " + list.Count);
        //Console.WriteLine("\nThe INSERT Method");
        //Console.WriteLine("I am inserting the number 15 at index: " + );
        //list.Insert(15,(list.Count - 1));
        //Console.WriteLine("New List: " + list.ToString());
        //Console.WriteLine("\nThe COUNT Method");
        //Console.WriteLine("The the count of this list is: " + list.Count);
        //Console.WriteLine("\nThe SEARCH Method");
        //Console.WriteLine("Searching for 1: " + list.Search(1));
        //Console.WriteLine("\nThe REMOVE Method");
        //Console.WriteLine(list.Remove());
        //Console.WriteLine("New List: " + list.ToString());
        //Console.WriteLine("\nThe COUNT Method");
        //Console.WriteLine("The the count of this list is: " + list.Count);
        //Console.WriteLine("\nThe REMOVELAST Method");
        //Console.WriteLine(list.RemoveLast());
        //Console.WriteLine("New List: " + list.ToString());
        //Console.WriteLine("\nThe COUNT Method");
        //Console.WriteLine("The the count of this list is: " + list.Count);
        //Console.WriteLine("\nThe CLEAR Method");
        //list.Clear();
        //Console.WriteLine("New List: " + list.ToString());
        //    Console.WriteLine("\nThe REMOVEAT Method");
        //    Console.WriteLine("What is at index " + index + ": " + list.Get(index));
        //    //Console.WriteLine("I am removing the element at index " + index + ": " + list.RemoveAt(index));
        //    Console.WriteLine("New List: " + list.ToString());
        //    Console.WriteLine("\nThe COUNT Method");
        //    Console.WriteLine("The the count of this list is: " + list.Count);
        //}
        public static void Main(string[] args)
        {
            BinarySearchTree<int> bst = new BinarySearchTree<int>();

            bst.Add(24);
            bst.Add(10);
            bst.Add(1337);

            //bst.Add(50);
            //bst.Add(1472);
            //bst.Add(72);
            //bst.Add(1360);
            //bst.Add(1345);
            //bst.Add(54);

            //bst.Add(20);
            //bst.Add(9);
            //bst.Add(19);
            //bst.Add(14);
            //bst.Add(67);

            //bst.Add(35);
            //bst.Add(80);
            //bst.Add(65);
            //bst.Add(24);
            //bst.Add(5);

            Console.WriteLine("Count:" + bst.Count);
            //Console.WriteLine("\ncontains 24: " + bst.Contains(24));

            //Console.WriteLine("\ncontains 0: " + bst.Contains(0));

            //Console.WriteLine("\nInorder:" + bst.Inorder());

            //Console.WriteLine("\nRemove: I'm removing 17 : " + bst.Remove(17));
            Console.WriteLine("\nInorder:" + bst.Inorder());

            Console.WriteLine("\nRemove: I'm removing 24 : " + bst.Remove(24));

            //bst.Clear();

            Console.WriteLine("\nCount:" + bst.Count);

            Console.WriteLine("\nInorder:" + bst.Inorder());
            //Console.WriteLine("\nPostorder:" + bst.Postorder());
            //Console.WriteLine("\nPreorder:" + bst.Preorder());

            //Console.WriteLine();
            //Console.WriteLine("\nPreorder:" + bst.Preorder());

            //Console.WriteLine();
            //Console.WriteLine("\nPostorder:" + bst.Postorder());

            foreach (var item in bst.ToArray())
            {
                Console.WriteLine(item);
            }

            Console.ReadLine();
        }
開發者ID:NUdbrown,項目名稱:Algo2Assignments,代碼行數:101,代碼來源:Program.cs


注:本文中的BinarySearchTree.ToArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。