1 | /**
|
---|
2 | * @file list.c
|
---|
3 | * @author myusgun <myusgun@gmail.com>
|
---|
4 | */
|
---|
5 | #include "cf_list.h"
|
---|
6 | #include "cf_debug.h"
|
---|
7 |
|
---|
8 | int main (void)
|
---|
9 | {
|
---|
10 | long long int iter = 0;
|
---|
11 | int result = 0;
|
---|
12 | long long int element = 0;
|
---|
13 | cf_ctx list = NULL;
|
---|
14 | cf_traverser trav = NULL;
|
---|
15 |
|
---|
16 | result = CF_List_Create (&list);
|
---|
17 | if (result < 0)
|
---|
18 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
19 |
|
---|
20 | for (iter = 0 ; iter < 10 ; iter++)
|
---|
21 | {
|
---|
22 | result = CF_List_InsertBefore (list, trav, (void *)iter);
|
---|
23 | if (result < 0)
|
---|
24 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
25 | }
|
---|
26 |
|
---|
27 | result = CF_List_Front (list, &trav);
|
---|
28 | if (result < 0)
|
---|
29 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
30 |
|
---|
31 | for (iter = 0 ; iter < 5 ; iter++)
|
---|
32 | {
|
---|
33 | result = CF_List_Next (&trav);
|
---|
34 | if (result < 0)
|
---|
35 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
36 | }
|
---|
37 |
|
---|
38 | result = CF_List_InsertBefore (list, trav, (void *)100);
|
---|
39 | if (result < 0)
|
---|
40 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
41 |
|
---|
42 | result = CF_List_InsertAfter (list, trav, (void *)200);
|
---|
43 | if (result < 0)
|
---|
44 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
45 |
|
---|
46 | for (CF_List_Front (list, &trav) ; trav != NULL ; CF_List_Next (&trav))
|
---|
47 | {
|
---|
48 | result = CF_List_Get (trav, (void **)&element);
|
---|
49 | if (result < 0)
|
---|
50 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
51 |
|
---|
52 | CF_DEBUG_PRINT (stderr, "%d \n", element);
|
---|
53 | }
|
---|
54 |
|
---|
55 | result = CF_List_Destroy (list);
|
---|
56 | if (result < 0)
|
---|
57 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
58 |
|
---|
59 | return 0;
|
---|
60 | }
|
---|