summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/priorityqueues/new_pque.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc/examples/priorityqueues/new_pque.c')
-rw-r--r--misc/examples/priorityqueues/new_pque.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/misc/examples/priorityqueues/new_pque.c b/misc/examples/priorityqueues/new_pque.c
new file mode 100644
index 00000000..16823bb6
--- /dev/null
+++ b/misc/examples/priorityqueues/new_pque.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+typedef struct Point { int x, y; } Point;
+
+#define i_type PointQ
+#define i_key Point
+#define i_less(a, b) a->x < b->x || (a->x == b->x && a->y < b->y)
+#include <stc/cpque.h>
+
+
+int main(void)
+{
+ PointQ pque = c_init(PointQ, {{23, 80}, {12, 32}, {54, 74}, {12, 62}});
+ // print
+ for (; !PointQ_empty(&pque); PointQ_pop(&pque))
+ {
+ const Point *v = PointQ_top(&pque);
+ printf(" (%d,%d)", v->x, v->y);
+ }
+ puts("");
+ PointQ_drop(&pque);
+}