summaryrefslogtreecommitdiffstats
path: root/linked_list.h
diff options
context:
space:
mode:
Diffstat (limited to 'linked_list.h')
-rw-r--r--linked_list.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/linked_list.h b/linked_list.h
new file mode 100644
index 0000000..aefdf29
--- /dev/null
+++ b/linked_list.h
@@ -0,0 +1,22 @@
+#pragma once
+
+struct list_item {
+ int value;
+ struct list_item *next;
+};
+
+/* Put x at the end of the list. */
+void append(struct list_item *first, int x);
+
+/* Put x at the beginning of the list. */
+void prepend(struct list_item *first, int x);
+
+/* Print att elements in the list. */
+void print(struct list_item *first);
+
+/* Find the first element in the list larger than x and input x right before
+ * that element. */
+void input_sorted(struct list_item *first, int x);
+
+/* Free everything dynamically located. */
+void clear(struct list_item *first);