Rev | Line | |
---|
[110] | 1 | /**
|
---|
| 2 | * @file queue.c
|
---|
| 3 | * @author myusgun <myusgun@gmail.com>
|
---|
| 4 | */
|
---|
| 5 | #include "cf_queue.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;
|
---|
[110] | 13 | CF_Queue_Ctx ctx = NULL;
|
---|
| 14 |
|
---|
| 15 | // create
|
---|
| 16 | result = CF_Queue_CreateCtx (&ctx);
|
---|
| 17 | if (result < 0)
|
---|
| 18 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
| 19 |
|
---|
| 20 | // insert
|
---|
| 21 | for (iter = 0 ; iter < 10 ; iter++)
|
---|
| 22 | {
|
---|
| 23 | result = CF_Queue_Put (ctx, (void *)iter);
|
---|
| 24 | if (result < 0)
|
---|
| 25 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | // move next
|
---|
| 29 | for (iter = 0 ; iter < 10 ; iter++)
|
---|
| 30 | {
|
---|
| 31 | result = CF_Queue_Front (ctx, (void **)&element);
|
---|
| 32 | if (result < 0)
|
---|
| 33 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
| 34 | else
|
---|
| 35 | CF_DEBUG_PRINT (stderr, "front : %4d\n", element);
|
---|
| 36 |
|
---|
| 37 | result = CF_Queue_Get (ctx, (void **)&element);
|
---|
| 38 | if (result < 0)
|
---|
| 39 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
| 40 | else
|
---|
| 41 | CF_DEBUG_PRINT (stderr, "got : %4d\n", element);
|
---|
| 42 |
|
---|
| 43 | CF_DEBUG_PRINT (stderr, "\n");
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | // destroy
|
---|
| 47 | result = CF_Queue_DestroyCtx (ctx);
|
---|
| 48 | if (result < 0)
|
---|
| 49 | CF_DEBUG_PRINT (stderr, "error %d\n", result);
|
---|
| 50 |
|
---|
| 51 | return 0;
|
---|
| 52 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.