Website Summary Files Commits Branches @commit @diff @stats
path: root / Seminar04 / insert-at-beg.cpp
diff options
context:
space:
mode:
Commit3de7b99fbbfdbb44cfddabf6a697d5c3335bdacb (patch)
Author
 Stoycho Kyosev <stoycho.kk@gmail.com>
2022-10-26 15:43:06 +0300
Committer
 Stoycho Kyosev <stoycho.kk@gmail.com>
2022-10-26 15:43:06 +0300
Filesa72acd5b4d7b4fcc3da4939e18ef864ee58bc064 /Seminar04/insert-at-beg.cpp
Data-structures-and-algorithms-3de7b99fbbfdbb44cfddabf6a697d5c3335bdacb.tar
Data-structures-and-algorithms-3de7b99fbbfdbb44cfddabf6a697d5c3335bdacb.tar.gz
Data-structures-and-algorithms-3de7b99fbbfdbb44cfddabf6a697d5c3335bdacb.zip
Parent0480ca20fabdb9373b64c353c90de47e7f97d394 (diff)
Add Seminar04
1 files changed, 20 insertions, 0 deletions
-rw-r--r--Seminar04/insert-at-beg.cpp20
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<class T>
+void insertAtBegin(LinkedListNode<T>*& ll, const T& elem) {
+ LinkedListNode<T>* toInsert = new LinkedListNode(elem, ll);
+ ll = toInsert;
+}
+
+void example() {
+ LinkedListNode<int>* 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