[109] | 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;
|
---|
[118] | 12 | long long int element = 0;
|
---|
[151] | 13 | cf_ctx list = NULL;
|
---|
| 14 | cf_traverser trav = NULL;
|
---|
[109] | 15 |
|
---|
[151] | 16 | result = CF_List_Create (&list);
|
---|
[109] | 17 | if (result < 0)
|
---|
| 18 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
| 19 |
|
---|
| 20 | for (iter = 0 ; iter < 10 ; iter++)
|
---|
| 21 | {
|
---|
[151] | 22 | result = CF_List_InsertBefore (list, trav, (void *)iter);
|
---|
[109] | 23 | if (result < 0)
|
---|
| 24 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
| 25 | }
|
---|
| 26 |
|
---|
[151] | 27 | result = CF_List_Front (list, &trav);
|
---|
[109] | 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 |
|
---|
[151] | 38 | result = CF_List_InsertBefore (list, trav, (void *)100);
|
---|
[109] | 39 | if (result < 0)
|
---|
| 40 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
| 41 |
|
---|
[151] | 42 | result = CF_List_InsertAfter (list, trav, (void *)200);
|
---|
[109] | 43 | if (result < 0)
|
---|
| 44 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
| 45 |
|
---|
[151] | 46 | for (CF_List_Front (list, &trav) ; trav != NULL ; CF_List_Next (&trav))
|
---|
[109] | 47 | {
|
---|
[151] | 48 | result = CF_List_Get (trav, (void **)&element);
|
---|
[109] | 49 | if (result < 0)
|
---|
| 50 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
| 51 |
|
---|
| 52 | CF_DEBUG_PRINT (stderr, "%d \n", element);
|
---|
| 53 | }
|
---|
| 54 |
|
---|
[151] | 55 | result = CF_List_Destroy (list);
|
---|
[109] | 56 | if (result < 0)
|
---|
| 57 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
| 58 |
|
---|
| 59 | return 0;
|
---|
| 60 | }
|
---|