Skip to content

Instantly share code, notes, and snippets.

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

  • Save BogdanAriton/1327fdb8faa81f7fbd380ca687e9ca03 to your computer and use it in GitHub Desktop.

Select an option

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