示例#1
0
文件: Program.cs 项目: dusansimic/ntp
        static void Main(string[] args)
        {
            System.Console.WriteLine("Start");
            IntList lista1 = new IntList();
            IntList lista2 = new IntList();

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

            lista1.RemoveDuplicates();

            System.Console.WriteLine(lista1);
        }
示例#2
0
文件: IntList.cs 项目: dusansimic/ntp
        // Nije gotova
        public void Reverse()
        {
            if (head == null)
            {
                return;
            }

            IntList lista = new IntList();
            IntNode curr  = head.Prev;

            while (curr != head)
            {
                lista.AddLast(curr.Data);
                System.Console.WriteLine(curr.Data);
                curr = curr.Prev;
            }

            Clear();
            head = lista.GetFirst();
        }
示例#3
0
文件: IntList.cs 项目: dusansimic/ntp
        public void Megre(IntList lista)
        {
            if (head == null)
            {
                head = lista.GetFirst();
                return;
            }
            if (lista == null)
            {
                return;
            }

            IntNode thisTail = head.Prev;
            IntNode thisHead = head;
            IntNode newTail  = lista.GetLast();
            IntNode newHead  = lista.GetFirst();

            thisTail.Next = newHead;
            newHead.Prev  = thisTail;
            newTail.Next  = thisHead;
            thisHead.Prev = newTail;
        }