示例#1
0
文件: IntList.cs 项目: dusansimic/ntp
        public void AddRangeLast(IntList list)
        {
            IntNode curr = list.Head();

            while (curr != null)
            {
                AddLast(curr.Data);
                curr = curr.Next;
            }
        }
示例#2
0
文件: IntList.cs 项目: dusansimic/ntp
        public void AddRangeFirst(IntList list)
        {
            IntList newList = new IntList();
            IntNode curr    = list.Head();

            while (curr.Next != null)
            {
                newList.AddLast(curr.Data);
                curr = curr.Next;
            }

            newList.AddLast(curr.Data, head);
            head = newList.Head();
        }
示例#3
0
文件: Program.cs 项目: dusansimic/ntp
        static void Main(string[] args)
        {
            IntList lista1 = new IntList();
            IntList lista2 = new IntList();

            lista1.AddLast(1);
            lista1.AddLast(2);
            lista1.AddLast(3);

            System.Console.WriteLine(lista1);

            lista1.Reverse();

            System.Console.WriteLine(lista1);
        }
示例#4
0
文件: IntList.cs 项目: dusansimic/ntp
        public void Reverse()
        {
            IntList newList = new IntList();

            int k = 1;

            for (int i = 0; i < Length(); i++)
            {
                IntNode curr = head;

                for (int j = 0; j < Length() - k; j++)
                {
                    curr = curr.Next;
                }

                newList.AddLast(curr.Data);

                k++;
            }

            head = newList.Head();
        }