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


C# ArrayList.AddRepeatedly方法代码示例

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


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

示例1: DoTest

        public static void DoTest()
        {
            int index = 0;
            DataStructures.Lists.ArrayList<long> arrayList = new DataStructures.Lists.ArrayList<long> ();

            for (long i = 1; i < 1000000; ++i)
            {
                arrayList.Add (i);
            }

            for (int i = 1000; i < 1100; i++)
            {
                arrayList.RemoveAt (i);
            }

            for (int i = 100000; i < 100100; i++)
            {
                arrayList.Remove (i);
            }

            var allNumbersGreatorThanNineHundK = arrayList.FindAll (item => item > 900000);
            Debug.Assert (allNumbersGreatorThanNineHundK.Count > 0, "Count check failed!");

            long nineHundK = arrayList.Find (item => item == 900000);

            var indexIfNineHundK = arrayList.FindIndex (item => item == nineHundK);
            Debug.Assert (indexIfNineHundK != -1, "Wrong index!");

            index = 900000;
            arrayList.InsertAt (99999, index);
            arrayList.InsertAt (99999, index);
            arrayList.InsertAt (99999, index);
            arrayList.InsertAt (99999, index);
            arrayList.InsertAt (99999, index);

            var allNines = arrayList.FindAll (item => item == 99999);
            Debug.Assert (allNines.Count == 1, "Wrong result!");

            bool doesMillionExist = arrayList.Exists (item => item == 1000000);
            Debug.Assert (doesMillionExist == false, "Wrong result!");

            bool doesEightsExists = arrayList.Contains (88888);
            Debug.Assert (doesEightsExists == true, "Wrong result!");

            //arrayList.Reverse ();

            var arrayList2 = new ArrayList<int> ();
            arrayList2.Add (0);
            arrayList2.Add (10);
            arrayList2.Add (20);
            arrayList2.Add (30);
            arrayList2.Add (40);
            arrayList2.Add (50);
            arrayList2.Add (60);
            arrayList2.Add (70);
            arrayList2.Add (80);
            arrayList2.Add (90);
            arrayList2.Add (100);

            Console.WriteLine(arrayList2.ToHumanReadable (addHeader: true));

            var arrayList3 = arrayList.GetRange (0, 100);
            Console.WriteLine(arrayList3.ToHumanReadable (addHeader: true));

            /****************************************************************/

            arrayList = new ArrayList<long> ();
            arrayList.AddRepeatedly (11, 32);
        }
开发者ID:natanbr,项目名称:C-Sharp-Algorithms,代码行数:69,代码来源:ArrayListTest.cs


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