]> code.delx.au - pulseaudio/blob - src/tests/prioq-test.c
120b512bcd08bec668c9f7245e530c747e984fc4
[pulseaudio] / src / tests / prioq-test.c
1 #ifdef HAVE_CONFIG_H
2 #include <config.h>
3 #endif
4
5 #include <pulsecore/prioq.h>
6 #include <pulsecore/macro.h>
7
8 #define N 1024
9
10 int main(int argc, char *argv[]) {
11 pa_prioq *q;
12 unsigned i;
13
14 srand(0);
15
16 q = pa_prioq_new(pa_idxset_trivial_compare_func);
17
18 /* Fill in 1024 */
19 for (i = 0; i < N; i++)
20 pa_prioq_put(q, PA_UINT_TO_PTR((unsigned) rand()));
21
22 /* Remove half of it again */
23 for (i = 0; i < N/2; i++){
24 unsigned u = PA_PTR_TO_UINT(pa_prioq_pop(q));
25 pa_log("%16u", u);
26 }
27
28 pa_log("Refilling");
29
30 /* Fill in another 1024 */
31 for (i = 0; i < N; i++)
32 pa_prioq_put(q, PA_UINT_TO_PTR((unsigned) rand()));
33
34
35 /* Remove everything */
36 while (!pa_prioq_isempty(q)) {
37 unsigned u = PA_PTR_TO_UINT(pa_prioq_pop(q));
38 pa_log("%16u", u);
39 }
40
41 pa_prioq_free(q, NULL, NULL);
42
43 return 0;
44 }