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


C# BinarySearchTree.CopyTo方法代碼示例

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


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

示例1: CopyTo_InOrder_Test

        public void CopyTo_InOrder_Test()
        {
            var bst = new BinarySearchTree<int>() { 90, 50, 150, 20, 75, 95, 175, 5, 25, 66, 80, 92, 111, 166, 200 };
            int[] expected = new int[] { 5, 20, 25, 50, 66, 75, 80, 90, 92, 95, 111, 150, 166, 175, 200 };
            int[] actual = new int[bst.Count];
            bst.CopyTo(actual, 0, TraversalMethod.Inorder);

            CollectionAssert.AreEqual(expected, actual, "Inorder bst traversal did not sort correctly");
        }
開發者ID:jojojojochen,項目名稱:Algorithm-Implementations,代碼行數:9,代碼來源:BinarySearchTreeTests.cs

示例2: CopyToTest

        public void CopyToTest([PexAssumeUnderTest]int[] elements, int position)
        {
            PexAssume.IsTrue(position >= 0 && position <= 1000);
            BinarySearchTree<int> bst = new BinarySearchTree<int>(elements);
            int[] actual = new int[bst.Count + position];

            if (position == 0)
            {
                bst.CopyTo(actual);
            }
            else
            {
                bst.CopyTo(actual, position);
            }

            //CollectionAssert.AreEqual(expected, actual);
            PexObserve.ValueForViewing<int[]>("SearchTree Contents", actual);
        }
開發者ID:taoxiease,項目名稱:asegrp,代碼行數:18,代碼來源:BinarySearchTreeTest.cs

示例3: CopyToStartingSpecifiedIndexTest

        public void CopyToStartingSpecifiedIndexTest()
        {
            BinarySearchTree<int> bst = new BinarySearchTree<int> { 12, 8, 6, 11, 42 };
            int[] expected = { 0, 0, 0, 12, 8, 42, 6, 11 };
            int[] actual = new int[bst.Count + 3];

            bst.CopyTo(actual, 3);

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

示例4: CopyToTest

        public void CopyToTest()
        {
            BinarySearchTree<int> bst = new BinarySearchTree<int> { 12, 8, 6, 11, 42 };
            int[] expected = { 12, 8, 42, 6, 11 };
            int[] actual = new int[bst.Count];

            bst.CopyTo(actual);

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

示例5: CopyToExample

        public void CopyToExample()
        {
            BinarySearchTreeBase<string, int> tree = new BinarySearchTree<string, int>
                                                         {
                                                             new KeyValuePair<string, int>("cat", 1),
                                                             new KeyValuePair<string, int>("dog", 2),
                                                             new KeyValuePair<string, int>("canary", 3)
                                                         };

            // Create a new array of length 3 to copy the elements into.
            var values = new KeyValuePair<string, int>[3];
            tree.CopyTo(values, 0);
        }
開發者ID:havok,項目名稱:ngenerics,代碼行數:13,代碼來源:BinarySearchTreeBaseExamples.cs


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