I need a swapList(LinkedList& Other) function in charge of basically swapping the values of two lists. Currently, it takes the last element of Other and inputs it into the first element of *this. Then it also moves the last element of Other to the front of its list. Here's what I have so far:
Node *nodePtr = Other.head;
Node *temp = this->head;
while(nodePtr){
temp->value = nodePtr->value;
nodePtr->value = Other.head->value;
Other.head->value = temp->value;
nodePtr = nodePtr->next;
}
}
Now, I know of the copy-swap idiom which I believe means I can just call the swap function in the operator=() overload. I just can't seem to figure out the swap. I've played with it a bunch and this is neither my first, nor my last iteration of the function. Any help is much appreciated. Searches just yield swapping nodes in a single list.