Пример #1
0
        public static void TestList()
        {
            var list = new List <int>();

            for (var i = 0; i < N; i++)
            {
                list.AddLast(i);
            }
            Console.Write("Original list: " + list.PrintList());

            int pos = 5, data = 11;

            list.AddFirst(data);
            Console.Write("Add the first element " + data + ": " + list.PrintList());

            data = -12;
            list.AddLast(data);
            Console.Write("Add the last element " + data + ": " + list.PrintList());

            list.Insert(pos, data);
            Console.Write("Insert " + data + " in position " + pos + ": " + list.PrintList());

            pos = 3;
            list.Remove(pos);
            Console.Write("Remove element with position " + pos + ": " + list.PrintList());

            list.Reverse();
            Console.Write("Reverse list: " + list.PrintList());

            list.RemoveFirst();
            Console.Write("Remove the first element: " + list.PrintList());

            list.RemoveLast();
            Console.Write("Remove the last element: " + list.PrintList());
            Console.Write("TestList completed\n\n");
        }