Beispiel #1
0
        public void TestAddRange()
        {
            var list = _newList();

            list.AddRange(Iterable.Range(1, 3));
            list.AddRange(Enumerable.Range(5, 3));
            ExpectList(list, 1, 2, 3, 5, 6, 7);
            list.AddRange(Iterable.Range(10, 2));
            list.AddRange(Enumerable.Range(20, 2));
            ExpectList(list, 1, 2, 3, 5, 6, 7, 10, 11, 20, 21);
            list.AddRange(Iterable.Single(30));
            list.AddRange(Enumerable.Range(40, 1));
            ExpectList(list, 1, 2, 3, 5, 6, 7, 10, 11, 20, 21, 30, 40);
            list.AddRange(Iterable.Repeat(0, 0));
            list.AddRange(Enumerable.Repeat(0, 0));
            ExpectList(list, 1, 2, 3, 5, 6, 7, 10, 11, 20, 21, 30, 40);

            list.AddRange(Iterable.Single(-99));
            if (Enumerable.First(list) == -99)
            {
                // It's a sorted list.
                list.AddRange(Iterable.Single(4));
                ExpectList(list, -99, 1, 2, 3, 4, 5, 6, 7, 10, 11, 20, 21, 30, 40);
                list.AddRange(Enumerable.Range(-2, 3));
                ExpectList(list, -99, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 20, 21, 30, 40);
                list.AddRange(Enumerable.Range(12, 8));
                ExpectList(list, -99, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 30, 40);
            }
            else
            {
                ExpectList(list, 1, 2, 3, 5, 6, 7, 10, 11, 20, 21, 30, 40, -99);
            }
        }
Beispiel #2
0
 public void Resize(int newSize)
 {
     if (newSize < Count)
     {
         RemoveRange(newSize, Count - newSize);
     }
     else if (newSize > Count)
     {
         InsertRange(Count, (ISource <T>)Iterable.Repeat(default(T), newSize - Count));
     }
 }