Skip to content

Instantly share code, notes, and snippets.

@BogdanAriton
Created June 15, 2021 15:19
Show Gist options
  • Select an option

  • Save BogdanAriton/1e1bd2f5ca15c34f88fb29a725019697 to your computer and use it in GitHub Desktop.

Select an option

Save BogdanAriton/1e1bd2f5ca15c34f88fb29a725019697 to your computer and use it in GitHub Desktop.
void push_back(const Data &data) noexcept
{
// if the list is empty we're going to add head
if (isEmpty())
{
head = std::make_unique<Node>(data, nullptr);
}
else
{
Node *current = head.get();
while (current->next != nullptr)
{
current = current->next.get();
}
current->next = std::make_unique<Node>(data, nullptr);
}
size++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment