Created
June 15, 2021 15:33
-
-
Save BogdanAriton/2a0b5d569be8045371e159a4b00c7168 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Iterator insert(const Iterator &pos, const Data &value) | |
{ | |
if (pos.current_node != nullptr) | |
{ | |
node_ptr newNode = std::make_unique<Node>(value); | |
newNode->next = std::move(pos.current_node->next); | |
if (pos.previous_node == nullptr) | |
{ | |
head = std::move(newNode); | |
size++; | |
return Iterator(head); | |
} | |
else | |
{ | |
pos.previous_node->next = std::move(newNode); | |
size++; | |
return Iterator(pos.previous_node->next); | |
} | |
} | |
return pos; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment