当前位置: 首页>>代码示例>>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;未经允许,请勿转载。