svolume: add comment
[pulseaudio-mirror.git] / src / tests / prioq-test.c
blob120b512bcd08bec668c9f7245e530c747e984fc4
1 #ifdef HAVE_CONFIG_H
2 #include <config.h>
3 #endif
5 #include <pulsecore/prioq.h>
6 #include <pulsecore/macro.h>
8 #define N 1024
10 int main(int argc, char *argv[]) {
11 pa_prioq *q;
12 unsigned i;
14 srand(0);
16 q = pa_prioq_new(pa_idxset_trivial_compare_func);
18 /* Fill in 1024 */
19 for (i = 0; i < N; i++)
20 pa_prioq_put(q, PA_UINT_TO_PTR((unsigned) rand()));
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);
28 pa_log("Refilling");
30 /* Fill in another 1024 */
31 for (i = 0; i < N; i++)
32 pa_prioq_put(q, PA_UINT_TO_PTR((unsigned) rand()));
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);
41 pa_prioq_free(q, NULL, NULL);
43 return 0;