Esempio n. 1
0
        public void TestReverseLinkedList()
        {
            var r = ReverseLinkedList.Reserve(MyLinkList.BuildListNodeFromArray(new[] { 1, 2, 3, 4, 5 }));

            Assert.AreEqual(r.Next.Val, 5);
            Assert.AreEqual(r.Next.Next.Val, 4);
            Assert.AreEqual(r.Next.Next.Next.Next.Next.Val, 1);

            r = ReverseLinkedList.Reserve_Recursive(MyLinkList.BuildListNodeFromArray(new[] { 1, 2, 3, 4, 5 }));
            Assert.AreEqual(r.Next.Val, 5);
            Assert.AreEqual(r.Next.Next.Val, 4);
            Assert.AreEqual(r.Next.Next.Next.Next.Next.Val, 1);
        }