summaryrefslogtreecommitdiffhomepage
path: root/examples/priority.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-09-03 12:59:41 +0200
committerTyge Løvset <[email protected]>2020-09-03 12:59:41 +0200
commita4e2ee22fd57665d2388d5debc17db896a4a389f (patch)
tree6a3a88772cd9d3b604f9def4c0579ed941983f61 /examples/priority.c
parentaaa3d7f6a107a668b1f24d8ed061fe74237d9883 (diff)
downloadSTC-modified-a4e2ee22fd57665d2388d5debc17db896a4a389f.tar.gz
STC-modified-a4e2ee22fd57665d2388d5debc17db896a4a389f.zip
Changed constant <container>_init to <container>_ini to avoid conflict with <container>_init() method.
Reverted name cprique back to cpqueue.
Diffstat (limited to 'examples/priority.c')
-rw-r--r--examples/priority.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/examples/priority.c b/examples/priority.c
index fc0526bf..82e78621 100644
--- a/examples/priority.c
+++ b/examples/priority.c
@@ -2,34 +2,34 @@
#include <stdio.h>
#include <time.h>
#include <stc/cvec.h>
-#include <stc/cprique.h>
+#include <stc/cpqueue.h>
#include <stc/cmap.h>
#include <stc/crandom.h>
declare_cvec(i, int64_t);
-declare_cprique(i, cvec_i, >); // min-heap (increasing values)
+declare_cpqueue(i, cvec_i, >); // min-heap (increasing values)
int main() {
size_t N = 10000000;
crand_rng64_t pcg = crand_rng64_init(time(NULL));
crand_uniform_i64_t dist = crand_uniform_i64_init(pcg, 0, N * 10);
- cprique_i heap = cprique_i_init();
+ cpqueue_i heap = cpqueue_i_init();
// Push ten million random numbers to priority queue
for (int i=0; i<N; ++i)
- cprique_i_push(&heap, crand_uniform_i64(&dist));
+ cpqueue_i_push(&heap, crand_uniform_i64(&dist));
// push some negative numbers too.
- c_push(&heap, cprique_i, c_items(-231, -32, -873, -4, -343));
+ c_push(&heap, cpqueue_i, c_items(-231, -32, -873, -4, -343));
for (int i=0; i<N; ++i)
- cprique_i_push(&heap, crand_uniform_i64(&dist));
+ cpqueue_i_push(&heap, crand_uniform_i64(&dist));
// Extract the hundred smallest.
for (int i=0; i<100; ++i) {
- printf("%zd ", *cprique_i_top(&heap));
- cprique_i_pop(&heap);
+ printf("%zd ", *cpqueue_i_top(&heap));
+ cpqueue_i_pop(&heap);
}
- cprique_i_destroy(&heap);
+ cpqueue_i_destroy(&heap);
}