Website Summary Files Commits Branches @commit @diff @stats
path: root / Seminar04 / insert-at-beg.cpp
diff options
context:
space:
mode:
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