aboutsummaryrefslogtreecommitdiff
path: root/Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.h
diff options
context:
space:
mode:
Diffstat (limited to 'Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.h')
-rw-r--r--Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.h b/Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.h
new file mode 100644
index 0000000..1574b2f
--- /dev/null
+++ b/Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.h
@@ -0,0 +1,42 @@
+#ifndef LINKED_LIST_H
+#define LINKED_LIST_H
+
+#include <stddef.h>
+
+typedef struct node {
+ void *data;
+ struct node *next;
+} node_t;
+
+
+typedef struct list_t {
+ node_t *head;
+ node_t *it;
+ node_t *prev_it;
+} list_t;
+
+/* Creates an empty list. */
+list_t create_list();
+
+/* Insert a new node in the begining of a list. */
+void insert(list_t *list, void *data, size_t data_size);
+
+/* Erases first node from the list. */
+void erase(list_t *list);
+
+/* Erases element under iterator and sets iterator to the next one. */
+void erase_it(list_t *list);
+
+/* Moves iterator one step. */
+void iterate(list_t *list);
+
+/* Resets the iterator.
+ * Should execute the function after if you want to itarate unless you didnt insert or erase anything from the list.
+ */
+void reset(list_t *list);
+
+/* Deletes the whole list. */
+void free_list(list_t *list);
+
+
+#endif \ No newline at end of file