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


C# SinglyLinkedList.CopyTo方法代码示例

本文整理汇总了C#中SinglyLinkedList.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# SinglyLinkedList.CopyTo方法的具体用法?C# SinglyLinkedList.CopyTo怎么用?C# SinglyLinkedList.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SinglyLinkedList的用法示例。


在下文中一共展示了SinglyLinkedList.CopyTo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyToTest

        public void CopyToTest()
        {
            // NOTE: the Add method, adds them to the front of the list, therefore the list is in reverse
            var list = new SinglyLinkedList<int> { 1, 0, -1 };
            var expected = new int[] { -1, 0, 1 };
            var actual = new int[list.Count];
            list.CopyTo(actual, 0);

            CollectionAssert.AreEqual(expected, actual, "The arrays do not match");
        }
开发者ID:joshimoo,项目名称:JamLib,代码行数:10,代码来源:SinglyLinkedListTests.cs

示例2: TestSinglyLinkedListIndexer

        public void TestSinglyLinkedListIndexer()
        {
            SinglyLinkedList<string> list = new SinglyLinkedList<string>();
            list.Add("One");
            list.Add("Two");
            list.Add("Three");
            list[0] = "Zero";

            string[] array = new string[list.Count];
            list.CopyTo(array);
            Assert.AreEqual("Zero, Two, Three", string.Join(", ", array));
        }
开发者ID:Ivan-Dimitrov-bg,项目名称:.Net-framework,代码行数:12,代码来源:SinglyLinkedListTest.cs

示例3: TestSinglyLinkedListInsert_InsertAtTheEnd

        public void TestSinglyLinkedListInsert_InsertAtTheEnd()
        {
            SinglyLinkedList<string> list = new SinglyLinkedList<string>();
            list.Add("One");
            list.Add("Two");
            list.Add("Three");
            list[0] = "Zero";
            list.Insert(3, "Ten");

            string[] array = new string[list.Count];
            list.CopyTo(array);
            Assert.AreEqual("Zero, Two, Three, Ten", string.Join(", ", array));
        }
开发者ID:Ivan-Dimitrov-bg,项目名称:.Net-framework,代码行数:13,代码来源:SinglyLinkedListTest.cs

示例4: TestCopyToIndex

        public void TestCopyToIndex()
        {
            var expected = new int[4] { 0, 1, 2, 3 };

            var list = new SinglyLinkedList<int>(new int[2] { 2, 3 });
            var actual = new int[4] { 0, 1, -1, -1 };
            list.CopyTo(actual, 2);

            CollectionAssert.AreEqual(expected, actual);
        }
开发者ID:Bpoe,项目名称:Data-Structures-and-Algorithms,代码行数:10,代码来源:SinglyLinkedListTests.cs

示例5: TestCopyTo0

        public void TestCopyTo0()
        {
            var expected = new int[4] { 0, 1, 2, 3 };

            var list = new SinglyLinkedList<int>(expected);

            var actual = new int[4];
            list.CopyTo(actual, 0);

            CollectionAssert.AreEqual(expected, actual);
        }
开发者ID:Bpoe,项目名称:Data-Structures-and-Algorithms,代码行数:11,代码来源:SinglyLinkedListTests.cs

示例6: CopyToInvalidIndexTest

        public void CopyToInvalidIndexTest()
        {
            SinglyLinkedList<int> sll = new SinglyLinkedList<int> {10, 20, 30};
            int[] myArray = new int[sll.Count];

            sll.CopyTo(myArray, -1);
        }
开发者ID:robertrancz,项目名称:dsa,代码行数:7,代码来源:SinglyLinkedListTest.cs

示例7: CopyToIndexGteThanArrayTest

        public void CopyToIndexGteThanArrayTest()
        {
            SinglyLinkedList<int> sll = new SinglyLinkedList<int> {10, 20, 30};
            int[] myArray = new int[sll.Count];

            sll.CopyTo(myArray, 2);
        }
开发者ID:robertrancz,项目名称:dsa,代码行数:7,代码来源:SinglyLinkedListTest.cs

示例8: ArrayCopyWithDefinedStartIndexTest

        public void ArrayCopyWithDefinedStartIndexTest()
        {
            SinglyLinkedList<int> sll = new SinglyLinkedList<int> {10, 20, 30};
            int[] actual = new int[10];

            sll.CopyTo(actual, 6);

            Assert.AreEqual(10, actual[6]);
            Assert.AreEqual(20, actual[7]);
            Assert.AreEqual(30, actual[8]);
        }
开发者ID:robertrancz,项目名称:dsa,代码行数:11,代码来源:SinglyLinkedListTest.cs

示例9: CopyToInvalidIndexTest

        public void CopyToInvalidIndexTest([PexAssumeUnderTest]int[] melements, int position)
        {
            PexAssume.IsTrue(position >= -1 && position < melements.Length);
            PexAssume.IsTrue(melements.Length > 0);
            SinglyLinkedList<int> sll = new SinglyLinkedList<int>(melements);
            int[] myArray = new int[sll.Count + position];
            sll.CopyTo(myArray, position);

            int compPosition = position;
            if (position == -1)
                compPosition = 0;

            for (int i = position, j = 0; i < sll.Count; i++)
            {
                PexAssert.AreEqual(myArray[i], melements[i]);
            }
        }
开发者ID:taoxiease,项目名称:asegrp,代码行数:17,代码来源:SinglyLinkedListTest.cs


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