-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdllist_specific.c
More file actions
26 lines (21 loc) · 947 Bytes
/
dllist_specific.c
File metadata and controls
26 lines (21 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>
#include "../src/text.h"
#include "../src/lists/double/dllist.h"
int main() {
// Creating a list.
DoubleLinkedList *myList = dllist_create();
// Adding some data.
dllist_append(myList, text_copyA("Hello world !"), NULL);
dllist_append(myList, text_copyA("Lorem ipsum donor si amet."), NULL);
dllist_append(myList, text_copyA("Test 123"), NULL);
dllist_append(myList, text_copyA("I'm at the end :)"), NULL);
// Testing functions specific to double linked lists.
printf("Using `dllist_selectPrevious`:\n");
printf("> #3 by index: %s\n", (char *) (dllist_selectByIndex(myList, 2)->data));
printf("> #2 by previous: %s\n", (char *) (dllist_selectPrevious(myList)->data)); // Specific to dllist
printf("> #3 by next: %s\n", (char *) (dllist_selectNext(myList)->data));
printf("\n");
// Freeing the list and the strings from memory.
printf("Freeing the list...\n");
dllist_free(myList, &free, NULL);
}