blob: 120b512bcd08bec668c9f7245e530c747e984fc4 (
plain)
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
40
41
42
43
44
|
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <pulsecore/prioq.h>
#include <pulsecore/macro.h>
#define N 1024
int main(int argc, char *argv[]) {
pa_prioq *q;
unsigned i;
srand(0);
q = pa_prioq_new(pa_idxset_trivial_compare_func);
/* Fill in 1024 */
for (i = 0; i < N; i++)
pa_prioq_put(q, PA_UINT_TO_PTR((unsigned) rand()));
/* Remove half of it again */
for (i = 0; i < N/2; i++){
unsigned u = PA_PTR_TO_UINT(pa_prioq_pop(q));
pa_log("%16u", u);
}
pa_log("Refilling");
/* Fill in another 1024 */
for (i = 0; i < N; i++)
pa_prioq_put(q, PA_UINT_TO_PTR((unsigned) rand()));
/* Remove everything */
while (!pa_prioq_isempty(q)) {
unsigned u = PA_PTR_TO_UINT(pa_prioq_pop(q));
pa_log("%16u", u);
}
pa_prioq_free(q, NULL, NULL);
return 0;
}
|