diff options
| author | Tyge Løvset <[email protected]> | 2021-09-08 21:16:00 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-09-08 21:16:00 +0200 |
| commit | c86e3d30299baea44f98f153c4b01ea5e244feaa (patch) | |
| tree | 7de3a473408bdee0017d8efa452dd5a095b61177 /examples/priority.c | |
| parent | b9e58749fb77715f4635a45377350a75ce7e0948 (diff) | |
| download | STC-modified-c86e3d30299baea44f98f153c4b01ea5e244feaa.tar.gz STC-modified-c86e3d30299baea44f98f153c4b01ea5e244feaa.zip | |
Updated most examples to newstyle. Some changes in cpque/cstack.
Diffstat (limited to 'examples/priority.c')
| -rw-r--r-- | examples/priority.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/priority.c b/examples/priority.c index 4824a294..09ede43c 100644 --- a/examples/priority.c +++ b/examples/priority.c @@ -1,13 +1,12 @@ #include <stdio.h>
#include <time.h>
-#include <stc/cvec.h>
-#include <stc/cpque.h>
-#include <stc/cmap.h>
#include <stc/crandom.h>
-using_cvec(i, int64_t);
-using_cpque(i, cvec_i, -c_default_compare); // min-heap (increasing values)
+#define i_tag i
+#define i_val int64_t
+#define i_cmp -c_default_compare // min-heap (increasing values)
+#include <stc/cpque.h>
int main() {
size_t N = 10000000;
@@ -16,6 +15,7 @@ int main() { c_forauto (cpque_i, heap)
{
// Push ten million random numbers to priority queue
+ printf("Push %zu numbers\n", N);
c_forrange (N)
cpque_i_push(&heap, stc64_uniform(&rng, &dist));
@@ -25,7 +25,7 @@ int main() { c_forrange (N)
cpque_i_push(&heap, stc64_uniform(&rng, &dist));
- // Extract the hundred smallest.
+ puts("Extract the hundred smallest.");
c_forrange (100) {
printf("%zd ", *cpque_i_top(&heap));
cpque_i_pop(&heap);
|
