feat: generic linked list

This commit is contained in:
2026-03-26 13:15:40 +01:00
parent 087ad85dc7
commit c892d1dd4e
2 changed files with 24 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
#include "linked-list.hpp"
template <typename T> int insertNode(LinkedList<T> *list, T data) {
LinkedList<T> *node = new LinkedList<T>;
node->data = data;
if (list == nullptr) {
node->next = list;
list = node;
} else {
list->next = node;
}
return 0;
}
+8
View File
@@ -0,0 +1,8 @@
template <typename T>
struct LinkedList {
T data;
struct LinkedList* next;
};
template<typename T>
int insertNode(LinkedList<T> *, T);