示例#1
0
        public void TestFindBeginOfLoop()
        {
            /*
                           1-2-5-9
                         /       8
             11-12-15-18-        6
                         \       7
                          26-29-30
            */

            var ll = new LinkedList<int>
                                   (11);
            ll.Insert(new Node<int>(12));
            ll.Insert(new Node<int>(15));
            ll.Insert(new Node<int>(18));
            ll.Insert(new Node<int>(1));
            ll.Insert(new Node<int>(2));
            ll.Insert(new Node<int>(5));
            ll.Insert(new Node<int>(9));
            ll.Insert(new Node<int>(8));
            ll.Insert(new Node<int>(7));
            ll.Insert(new Node<int>(30));
            ll.Insert(new Node<int>(29));
            ll.Insert(new Node<int>(26));
            var node = ll.FindAt(3);
            ll.Last.Next = node;
            var found = ll.FindBeginingOfLoop(ll.First);
            Assert.IsTrue(found.Data == 18);
        }