From 3de7b99fbbfdbb44cfddabf6a697d5c3335bdacb Mon Sep 17 00:00:00 2001 From: Stoycho Kyosev Date: Wed, 26 Oct 2022 15:43:06 +0300 Subject: Add Seminar04 --- Seminar04/insert-at-beg.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Seminar04/insert-at-beg.cpp (limited to 'Seminar04/insert-at-beg.cpp') diff --git a/Seminar04/insert-at-beg.cpp b/Seminar04/insert-at-beg.cpp new file mode 100644 index 0000000..88c3d74 --- /dev/null +++ b/Seminar04/insert-at-beg.cpp @@ -0,0 +1,20 @@ +#include"linked-list-utils.h" + +template +void insertAtBegin(LinkedListNode*& ll, const T& elem) { + LinkedListNode* toInsert = new LinkedListNode(elem, ll); + ll = toInsert; +} + +void example() { + LinkedListNode* ll = new LinkedListNode(1, new LinkedListNode(2, new LinkedListNode(3))); + printLinkedList(ll); + insertAtBegin(ll, 0); + printLinkedList(ll); + freeList(ll); +} + +int main() { + + +} \ No newline at end of file -- cgit v1.3.1-23-gd82d