summaryrefslogtreecommitdiffstats
path: root/list.h
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2018-10-08 22:37:21 +0200
committerpgen <p.gen.progs@gmail.com>2018-10-08 22:37:21 +0200
commitfdc9bbedae48ef73e040b2ad0bd4d637261346f9 (patch)
treec391968bad1f7726d0ac3b8f38a2bd067d1b0c1b /list.h
parent7ec39d7df253dd6f7dc92854e5582949dfa823a5 (diff)
Rename ptrlist.[ch] to list.[ch]
Diffstat (limited to 'list.h')
-rw-r--r--list.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/list.h b/list.h
new file mode 100644
index 0000000..76c7b40
--- /dev/null
+++ b/list.h
@@ -0,0 +1,69 @@
+#ifndef LIST_H
+#define LIST_H
+
+typedef struct ll_node_s ll_node_t;
+typedef struct ll_s ll_t;
+
+/* ******************************* */
+/* Linked list specific structures */
+/* ******************************* */
+
+/* Linked list node structure */
+/* """""""""""""""""""""""""" */
+struct ll_node_s
+{
+ void * data;
+ struct ll_node_s * next;
+ struct ll_node_s * prev;
+};
+
+/* Linked List structure */
+/* """"""""""""""""""""" */
+struct ll_s
+{
+ ll_node_t * head;
+ ll_node_t * tail;
+ long len;
+};
+
+int
+ll_append(ll_t * const list, void * const data);
+
+#if 0 /* here for coherency but not used. */
+int ll_prepend(ll_t * const list, void *const data);
+
+void
+ll_insert_before(ll_t * const list, ll_node_t * node, void *const data);
+
+void
+ll_insert_after(ll_t * const list, ll_node_t * node, void *const data);
+#endif
+
+ll_node_t *
+ll_partition(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *),
+ void (*swap)(void *, void *));
+
+void
+ll_quicksort(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *),
+ void (*swap)(void * a, void *));
+
+void
+ll_sort(ll_t * list, int (*comp)(void *, void *),
+ void (*swap)(void * a, void *));
+
+int
+ll_delete(ll_t * const list, ll_node_t * node);
+
+ll_node_t *
+ll_find(ll_t * const, void * const, int (*)(const void *, const void *));
+
+void
+ll_init(ll_t * list);
+
+ll_node_t *
+ll_new_node(void);
+
+ll_t *
+ll_new(void);
+
+#endif