Skip to content

Instantly share code, notes, and snippets.

@BogdanAriton
Created June 15, 2021 15:33
Show Gist options
  • Save BogdanAriton/2a0b5d569be8045371e159a4b00c7168 to your computer and use it in GitHub Desktop.
Save BogdanAriton/2a0b5d569be8045371e159a4b00c7168 to your computer and use it in GitHub Desktop.
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