Beispiel #1
0
    public void RemoveSingleElementShouldHaveCorrectCount()
    {
        ReversedList <int> list = new ReversedList <int>();

        list.Add(0);
        list.RemoveAt(0);

        Assert.AreEqual(0, list.Count);
    }
Beispiel #2
0
    static void Main(string[] args)
    {
        var list = new ReversedList <int>();

        list.Add(0);
        list.Add(1);
        list.Add(2);
        list.RemoveAt(0);

        Console.WriteLine(list[0]);
    }
    public static void Main(string[] args)
    {
        var list = new ReversedList <int>();

        for (int i = 0; i <= 5; i++)
        {
            list.Add(i);
        }
        Console.WriteLine(list[5] + " " + list[0]);
        list.RemoveAt(4);

        Console.WriteLine(string.Join(" ", list));
        Console.WriteLine($"Capacity: {list.Capacity} {list.Count}");

        list.RemoveAt(0);
        Console.WriteLine(list[0]);
        Console.WriteLine(list[3]);

        Console.WriteLine(string.Join(" ", list));
        Console.WriteLine($"Capacity: {list.Capacity} {list.Count}");
    }
Beispiel #4
0
    public void RemoveSingleElementShouldHaveCorrectElements()
    {
        ReversedList <int> list = new ReversedList <int>();

        list.Add(0);
        list.Add(1);
        list.Add(2);
        list.RemoveAt(0);

        Assert.AreEqual(1, list[0]);
        Assert.AreEqual(2, list[1]);
    }
    static void Main(string[] args)
    {
        ReversedList <int> test = new ReversedList <int>();

        test.Add(0);
        test.Add(1);
        test.Add(2);
        test.Add(3);
        test.Add(4);
        test.RemoveAt(1);
        foreach (var item in test)
        {
            Console.WriteLine(item);
        }
    }
    static void Main()
    {
        var list = new ReversedList <int>();

        list.Add(5);
        list.Add(3);
        list.Add(2);
        list.Add(10);
        list.Add(7);
        list.Add(8);
        list.Add(9);
        Console.WriteLine("Count = {0}", list.Count);

        foreach (var item in list)
        {
            Console.WriteLine(item);
        }

        Console.WriteLine("--------------------");

        list.RemoveAt(1);
        foreach (var item in list)
        {
            Console.WriteLine(item);
        }
        Console.WriteLine("--------------------");

        list.RemoveAt(1);
        list.RemoveAt(2);

        foreach (var item in list)
        {
            Console.WriteLine(item);
        }
        Console.WriteLine("--------------------");
    }
Beispiel #7
0
    public static void Main()
    {
        ReversedList <int> reverse = new ReversedList <int>();

        reverse.Add(1);
        reverse.Add(2);
        reverse.Add(3);

        Console.WriteLine(reverse.RemoveAt(0));

        Console.WriteLine();

        foreach (var i in reverse)
        {
            Console.WriteLine(i);
        }
    }
Beispiel #8
0
    public static void Main(string[] args)
    {
        var list = new ReversedList <int>();

        for (int i = 1; i <= 10; i++)
        {
            list.Add(i);
        }

        Console.WriteLine(list[2]);
        list.RemoveAt(2);
        Console.WriteLine(list[2]);

        foreach (var el in list)
        {
            Console.WriteLine(el);
        }
    }
Beispiel #9
0
    public static void Main()
    {
        ReversedList <int> nums = new ReversedList <int>();

        nums.Add(1);
        nums.Add(2);
        nums.Add(3);
        nums.Add(4);
        nums.Add(5);
        Console.WriteLine(nums[3]);
        Console.WriteLine(nums.Count);
        Console.WriteLine(nums.Capacity);

        nums.RemoveAt(4);
        foreach (var num in nums)
        {
            Console.WriteLine(num);
        }
    }
Beispiel #10
0
    public void RemoveMultipleElements()
    {
        ReversedList <int> list = new ReversedList <int>();

        for (int i = 0; i < 100; i++)
        {
            list.Add(i);
        }

        for (int i = 0; i < 50; i++)
        {
            list.RemoveAt(0);
        }

        Assert.AreEqual(50, list.Count);
        for (int i = 0; i < 50; i++)
        {
            Assert.AreEqual(i + 50, list[i]);
        }
    }
Beispiel #11
0
    public static void Main()
    {
        ReversedList <int> reversedList = new ReversedList <int>();

        reversedList.Add(1);
        reversedList.Add(2);
        reversedList.Add(3);
        reversedList.Add(4);
        reversedList.Add(5);
        reversedList.Add(6);
        reversedList.Add(7);
        reversedList.Add(8);

        reversedList.RemoveAt(4);

        foreach (int num in reversedList)
        {
            Console.WriteLine(num);
        }
    }
Beispiel #12
0
    static void Main(string[] args)
    {
        ReversedList <int> reversed = new ReversedList <int>();

        reversed.Add(1);
        reversed.Add(2);
        reversed.Add(3);
        reversed.Add(4);
        reversed.Add(5);

        Console.WriteLine(reversed.RemoveAt(1));

        foreach (var item in reversed)
        {
            Console.WriteLine(item);
        }
        Console.WriteLine();
        Console.WriteLine(reversed[1]);
        reversed[1] = 5;
        Console.WriteLine(reversed[1]);
    }
Beispiel #13
0
 private static void Main(string[] args)
 {
     ReversedList<int> myList = new ReversedList<int>();
     Console.WriteLine("Capacity: {0}; Count: {1}", myList.Capacity, myList.Count);
     for (int i = 0; i < 4; i++)
     {
         myList.Add(i);
         Console.WriteLine(myList.ToString());
     }
     Console.WriteLine("Capacity: {0}; Count: {1}", myList.Capacity, myList.Count);
     myList.Add(4);
     Console.WriteLine(myList.ToString());
     Console.WriteLine("Capacity: {0}; Count: {1}", myList.Capacity, myList.Count);
     myList[1] = 666;
     Console.WriteLine(myList.ToString());
     Console.WriteLine("Capacity: {0}; Count: {1}", myList.Capacity, myList.Count);
     int remNum = myList.RemoveAt(1);
     Console.WriteLine("Removed value: {0}", remNum);
     Console.WriteLine(myList.ToString());
     Console.WriteLine("Capacity: {0}; Count: {1}", myList.Capacity, myList.Count);
 }
Beispiel #14
0
    public static void Main()
    {
        var reversedList = new ReversedList <int>();

        reversedList.Add(1);
        reversedList.Add(2);
        reversedList.Add(3);
        reversedList.Add(4);
        reversedList.Add(5);

        Console.WriteLine(reversedList[0]);
        Console.WriteLine(reversedList.Count);

        var removedElement = reversedList.RemoveAt(0);

        Console.WriteLine($"Removed element = {removedElement}");
        Console.WriteLine(reversedList.Count);

        foreach (var el in reversedList)
        {
            Console.WriteLine(el);
        }
    }
Beispiel #15
0
    static void Main(string[] args)
    {
        var reversed = new ReversedList <int>();

        reversed.Add(2);
        reversed.Add(2);
        reversed.Add(3);
        reversed.Add(4);

        reversed.Add(5);
        reversed.Add(6);
        reversed.RemoveAt(4);
        reversed[4] = 6;
        //reversed.RemoveAt(4);
        //reversed.RemoveAt(3);
        //reversed.RemoveAt(2);
        foreach (var item in reversed)
        {
            Console.Write(item + " ");
        }
        Console.WriteLine($"capacity -> {reversed.Capacity}");
        Console.WriteLine($"item at 3 -> {reversed[3]} ");
        Console.WriteLine($"item at 2 -> {reversed[2]} ");
    }
Beispiel #16
0
    public void RemoveAtInvalidPositionShouldThrow()
    {
        var list = new ReversedList <int>();

        list.RemoveAt(3);
    }
Beispiel #17
0
 public void RemoveAt()
 {
     R.RemoveAt(1);
     Assert.AreEqual(new[] { 5, 3, 2, 1 }, R);
 }