diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2020-12-01 13:33:34 +0100 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2020-12-01 13:33:34 +0100 |
commit | 00e5132a803f8781b6f538625ab99816b7b52d2d (patch) | |
tree | 726a07ea8b2b6f35135dd253ecd8dc0768b09f42 /dependencies/uthash/tests/test91.c | |
parent | 32b192df3b898b4199325309a6113ae7efa3556e (diff) | |
parent | c8bf38e5fb717d40635a2a89b22ed71b0de4266b (diff) |
Merge commit 'c8bf38e5fb717d40635a2a89b22ed71b0de4266b' as 'dependencies/uthash'
Diffstat (limited to 'dependencies/uthash/tests/test91.c')
-rw-r--r-- | dependencies/uthash/tests/test91.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/dependencies/uthash/tests/test91.c b/dependencies/uthash/tests/test91.c new file mode 100644 index 000000000..8c8f63e48 --- /dev/null +++ b/dependencies/uthash/tests/test91.c @@ -0,0 +1,54 @@ +#include <stdio.h> +#include "utlist.h" + +typedef struct el { + int id, score; + struct el *next, *prev; +} el; + +static int order_desc(el *a, el *b) +{ + return (a->score > b->score) ? -1 : (a->score < b->score); +} + +int main() +{ + int i; + el *head = NULL; + el els[15], *e; + + for (i=0; i<15; i++) { + els[i].id = (int)'a'+i; + els[i].score = i%7; + LL_INSERT_INORDER(head, &els[i], order_desc); + } + LL_FOREACH(head, e) { + printf("%c ", e->id); + } + printf("\n"); + + printf("DL_INSERT_INORDER\n"); + head = NULL; + for (i=0; i<15; i++) { + DL_INSERT_INORDER(head, &els[i], order_desc); + } + DL_FOREACH(head, e) { + printf("%c ", e->id); + } + printf("\n"); + + printf("CDL_INSERT_INORDER\n"); + head = NULL; + for (i=0; i<15; i++) { + CDL_INSERT_INORDER(head, &els[i], order_desc); + } + CDL_FOREACH(head, e) { + printf("%c ", e->id); + } + printf("\n"); + CDL_FOREACH2(head, e, prev) { + printf("%c ", e->id); + } + printf("\n"); + return 0; +} |