I have made a post here on code review which can be found here. I was told that my insertPosition function does not update head or tail. When I asked how some questions about this claim, my questions fell on deaf ears.
Here is the function:
template <class T>
void DoubleLinkedLists<T>::insertPosition(int pos, const T& theData) {
Node* current = head;
int i = 0;
while (current != nullptr) {
if (i++ == pos) {
Node* newNode = new Node;
newNode->data = theData;
// Let's do the wiring
newNode->previous = current->previous;
newNode->next = current;
if (newNode->previous != nullptr) { // If the node is inserted at the end
newNode->previous->next = newNode;
}
current->previous = newNode;
return;
}
current = current->next;
}
}
Does the latter function not update head or tail? If so, how should I change it?