Created
June 15, 2021 15:18
-
-
Save BogdanAriton/1327fdb8faa81f7fbd380ca687e9ca03 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
| 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