-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathqueue_u32.c
39 lines (32 loc) · 850 Bytes
/
queue_u32.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
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <cdada/queue.h>
int main(int args, char** argv){
uint32_t item;
cdada_queue_t* q = cdada_queue_create(uint32_t);
//Push {1,3,5,4,6,5}
item = 1;
cdada_queue_push(q, &item);
item = 3;
cdada_queue_push(q, &item);
item = 5;
cdada_queue_push(q, &item);
item = 4;
cdada_queue_push(q, &item);
item = 6;
cdada_queue_push(q, &item);
item = 5;
cdada_queue_push(q, &item);
fprintf(stdout, "The queue has a size of %u:\n", cdada_queue_size(q));
uint32_t val;
cdada_queue_front(q, &val);
fprintf(stdout, "Popping %u off the queue:\n", val);
cdada_queue_pop(q);
fprintf(stdout, "After removal of front, the queue has a size of %u, contents:\n",
cdada_queue_size(q));
cdada_queue_print(q, stdout);
//Don't leak
cdada_queue_destroy(q);
return EXIT_SUCCESS;
}