public bool Equals(IntList list) { if (GetLength() != list.GetLength()) { return(false); } IntNode curr1 = head; IntNode curr2 = list.GetHead(); if (curr1 == null && curr2 == null) { return(true); } else if (curr1 == null && curr2 != null) { return(false); } else if (curr1 != null && curr2 == null) { return(false); } while (curr1 != null) { if (curr1.Data != curr2.Data) { return(false); } curr1 = curr1.Next; curr2 = curr2.Next; } return(true); }
public void AddRange(int index, IntList list) { if (index < 0 || index >= GetLength()) { System.Console.WriteLine("Index nije unutar niza!"); return; } IntNode curr = list.GetHead(); if (head != null) { int i = index; while (curr != null) { Add(i, curr.Data); i++; curr = curr.Next; } } else { while (curr != null) { AddLast(curr.Data); curr = curr.Next; } } }
public void AddRangeLast(IntList list) { IntNode curr = list.GetHead(); while (curr != null) { AddLast(curr.Data); curr = curr.Next; } }
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(); }
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(); }