private void Swap(int pos1, int pos2) { Node n1 = getElementAt(pos1); Node n2 = getElementAt(pos2); n1.next = n2.next; n2.next = n1; if (pos1 > 0) { Node nant = getElementAt(pos1 - 1); nant.next = n2; } if (pos2 == 1 && pos1 == 0) first = n2; }
public void Add(Node n) { n.next = first; first = n; length++; }
public void Clear() { this.head = null; this.tail = null; this.size = 0; }
public MyList() { first = null; length = 0; }
public MyLinkedList() { this.head = null; this.tail = null; this.size = 0; }