-
Notifications
You must be signed in to change notification settings - Fork 37
/
listtest.c
49 lines (38 loc) · 925 Bytes
/
listtest.c
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "list.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char** argv){
printf("%ld\n", sizeof(struct list));
printf("%ld\n", sizeof(struct linked_node));
list_p list = create_list();
list_p list2 = create_list();
int x;
int * pi;
x = 0;
list_add(list, &x, sizeof(int));
list_remove(list, FRONT);
list_add(list, &x, sizeof(int));
list_remove(list, BACK);
for(x=0;x<10;x++){
list_add(list, (void*)&x, sizeof(int));
list_add(list2, (void*)&x, sizeof(int));
}
list_iter_p iter = list_iterator(list, FRONT);
while(list_next(iter)!=NULL){
pi = (int*)list_current(iter);
printf("%d\n", *pi);
}
destroy_list(list);
list_remove(list2, FRONT);
list_remove(list2, BACK);
free(iter);
iter = list_iterator(list2, 1);
while(list_prev(iter)!=NULL){
pi = (int*)list_current(iter);
printf("%d\n", *pi);
}
destroy_list(list2);
free(iter);
return 0;
}