Beispiel #1
0
        private static void AssertDoublyList(int assertsAmount)
        {
            for (int i = 0; i < assertsAmount; i++)
            {
                DoublyLinkedList <string> list = new DoublyLinkedList <string>();

                list.Add("a");
                list.RemoveAt(0);
                Assert("Null list", list.DisplayForward(), list.GetType().Name + "Remove at Count = 1");

                string expected = "0abcd6efghijklnopqrstuvwxy";

                string inverseExpected = expected.Reverse <char>().ToString();
                char[] aux             = expected.ToCharArray();
                Array.Reverse(aux);
                inverseExpected = new string(aux);

                FillListForAssert(list);
                Assert(expected, list.DisplayForward(), list.GetType().Name + "DisplayForward()");
                Assert(inverseExpected, list.DisplayBackward(), list.GetType().Name + "DisplayBackward()");
                list.Clear();
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            DoublyLinkedList <int> list = new DoublyLinkedList <int>();

            list.Add(1);
            list.Add(2);
            list.Add(3);
            list.Add(4);
            list.Add(5);
            list.Add(9);
            list.Add(10);
            list.Add(25);
            list.Add(99);
            list.Add(101);
            foreach (var item in list)
            {
                Console.WriteLine("Данный список: " + item);
            }

            foreach (var item in list.BackEnumerator())
            {
                Console.WriteLine("Обратный список: " + item);
            }
        }