Example #1
0
        public void AddRangeLast(IntList list)
        {
            IntNode curr = list.GetHead();

            while (curr != null)
            {
                AddLast(curr.Data);
                curr = curr.Next;
            }
        }
Example #2
0
        public void AddRangeFirst(IntList list)
        {
            IntList newList = new IntList();
            IntNode curr    = list.GetHead();

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

            newList.AddLast(curr.Data, head);
            head = newList.GetHead();
        }
Example #3
0
        static void Main(string[] args)
        {
            IntList lista = new IntList();

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

            System.Console.WriteLine(lista);

            lista.Reverse();

            System.Console.WriteLine(lista);

            lista.Clear();

            System.Console.WriteLine(lista);
        }
Example #4
0
        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++;
            }

            Clear();
            head = newList.GetHead();
        }