summaryrefslogtreecommitdiffstats
path: root/list.c
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2021-12-20 16:25:43 +0100
committerLouis Burda <quent.burda@gmail.com>2021-12-20 16:25:43 +0100
commitf07580d31d1148c4a1811c36b09ca0ad50d9576b (patch)
tree05a8fbb44af81f3b5937df80c5af3305ec3ed3c9 /list.c
parentfaee8e9c6db45c6adacfc5113d55927f92e8bf29 (diff)
downloadtmus-f07580d31d1148c4a1811c36b09ca0ad50d9576b.tar.gz
tmus-f07580d31d1148c4a1811c36b09ca0ad50d9576b.zip
Restructured repository and added automatic make dependency generation
Diffstat (limited to 'list.c')
-rw-r--r--list.c108
1 files changed, 0 insertions, 108 deletions
diff --git a/list.c b/list.c
deleted file mode 100644
index 29ddcf1..0000000
--- a/list.c
+++ /dev/null
@@ -1,108 +0,0 @@
-#include "list.h"
-#include "util.h"
-
-int
-list_empty(struct link *head)
-{
- return head->next == NULL;
-}
-
-int
-list_len(struct link *head)
-{
- struct link *iter;
- int len;
-
- ASSERT(head != NULL);
-
- len = 0;
- for (iter = head->next; iter; iter = iter->next)
- len += 1;
-
- return len;
-}
-
-int
-list_ffind(struct link *head, struct link *link)
-{
- struct link *iter;
-
- ASSERT(head != NULL);
-
- for (iter = head->next; iter && iter != link; iter = iter->next);
-
- return (iter == link);
-}
-
-struct link *
-link_back(struct link *link)
-{
- ASSERT(link != NULL);
-
- for (; link->next; link = link->next);
-
- return link;
-}
-
-void
-link_prepend(struct link *cur, struct link *link)
-{
- ASSERT(cur != NULL && link != NULL);
-
- link->prev = cur->prev;
- link->next = cur;
-
- if (link->prev)
- link->prev->next = link;
- if (link->next)
- link->next->prev = link;
-}
-
-void
-link_append(struct link *cur, struct link *link)
-{
- ASSERT(cur != NULL && link != NULL);
-
- link->prev = cur;
- link->next = cur->next;
-
- if (link->prev)
- link->prev->next = link;
- if (link->next)
- link->next->prev = link;
-}
-
-struct link *
-link_pop(struct link *link)
-{
- ASSERT(link != NULL);
-
- if (link->prev)
- link->prev->next = link->next;
- if (link->next)
- link->next->prev = link->prev;
-
- return link;
-}
-
-struct link *
-link_iter(struct link *link, int n)
-{
- int i;
-
- for (i = 0; i < n; i++) {
- if (!link) return NULL;
- link = link->next;
- }
-
- return link;
-}
-
-void
-list_push_back(struct link *cur, struct link *link)
-{
- struct link *back;
-
- back = link_back(cur);
- link_append(back, link);
-}