public void AddRangeLast(IntList list) { IntNode curr = list.Head(); while (curr != null) { AddLast(curr.Data); curr = curr.Next; } }
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(); }
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); }
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(); }