public List <int> getNodesInArray()
            {
                List <int>     nodes   = new List <int>();
                TestLinkedList current = this;

                while (current != null)
                {
                    nodes.Add(current.value);
                    current = (TestLinkedList)current.next;
                }
                return(nodes);
            }
            public TestLinkedList addMany(List <int> values)
            {
                TestLinkedList current = this;

                while (current.next != null)
                {
                    current = (TestLinkedList)current.next;
                }
                foreach (int value in values)
                {
                    current.next = new TestLinkedList(value);
                    current      = (TestLinkedList)current.next;
                }
                return(this);
            }
        static void Main(string[] args)
        {
            TestLinkedList list1 = new TestLinkedList(1);

            list1.addMany(new List <int>()
            {
                2, 4
            });
            TestLinkedList list2 = new TestLinkedList(1);

            list2.addMany(new List <int>()
            {
                3, 4
            });
            TestLinkedList output        = (TestLinkedList)mergeLinkedLists(list1, list2);
            List <int>     expectedNodes = new List <int>()
            {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };

            Console.ReadLine();
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            TestLinkedList.Run();

            Console.ReadKey();
        }