3 #include "prio-queue.h"
5 static int intcmp(const void *va
, const void *vb
, void *data
)
7 const int *a
= va
, *b
= vb
;
11 static void show(int *v
)
20 int cmd__prio_queue(int argc
, const char **argv
)
22 struct prio_queue pq
= { intcmp
};
25 if (!strcmp(*argv
, "get")) {
26 void *peek
= prio_queue_peek(&pq
);
27 void *get
= prio_queue_get(&pq
);
29 BUG("peek and get results do not match");
31 } else if (!strcmp(*argv
, "dump")) {
34 while ((peek
= prio_queue_peek(&pq
))) {
35 get
= prio_queue_get(&pq
);
37 BUG("peek and get results do not match");
40 } else if (!strcmp(*argv
, "stack")) {
43 int *v
= xmalloc(sizeof(*v
));
45 prio_queue_put(&pq
, v
);