Esempio n. 1
0
 public void AppendList(MyList <T> list1)
 {
     Current.Next = list1.Head;
     Current      = list1.Current;
 }
Esempio n. 2
0
        public static void Test()
        {
            var list = new MyList <int>();

            list.Insert(1);
            list.Insert(2);
            list.Insert(3);
            list.Insert(4);
            var tmpEnd = list.Current;

            list.Insert(5);
            list.Insert(6);
            list.Insert(7);

            var temList = list.Reverse1(list.Head.Next, tmpEnd);

            list.Head = list.MergeSort(list.Head);
            var tree = list.BuildBst(list.Head);

            //var head0 = SwapList<int>(list.Head);

            //reverse a like
            //list.Head = list.Reverse(list.Head);

            //list.Head = list.ReverseRecursive(list.Head);

            var list2 = new MyList <int>();

            list2.Insert(2);
            list2.Insert(9);
            list2.Insert(11);

            //list.Head = list.MergeSort(list.Head);
            //var result = MergeSortedList<int>(list.Head, list2.Head);

            //Node<int> result1 = RecurMergeSortedList<int>(list.Head, list2.Head);

            int length = 1;
            //var middle = list.FindMiddle(list.Head);
            //var middle = list.RecurFindMiddle(list.Head, list.Head);

            //var back = list.SplitInTheMiddle(list.Head);

            var head = list.MergeSort(list.Head);

            var list3 = new MyList <int>();

            list3.Insert(1);
            list3.Insert(4);
            list3.Insert(3);
            list3.Insert(2);
            list3.Insert(5);
            var head1 = list3.Head;
            var cur   = head1;
            var pre   = head1;

            while (cur.Next != null)
            {
                var next = cur.Next;
                cur.Next  = next.Next;
                next.Next = cur;
                if (pre == head1)
                {
                    head1 = next;
                }
                else
                {
                    pre.Next = next;
                }
                pre = cur;
                cur = cur.Next;
            }
            //var result = list3.PartitionList(list3.Head, 3);
        }