summaryrefslogtreecommitdiffhomepage
path: root/examples/priority.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-08-28 16:08:08 +0200
committerTyge Løvset <[email protected]>2020-08-28 16:08:08 +0200
commit47de9987a623e8374915af40d67d72dcb56e4283 (patch)
tree44ad1af184a3121d87a3281ff04546452b927819 /examples/priority.c
parentb29771837b5e37fc9175dc43ab7108d01aaaeba1 (diff)
downloadSTC-modified-47de9987a623e8374915af40d67d72dcb56e4283.tar.gz
STC-modified-47de9987a623e8374915af40d67d72dcb56e4283.zip
Some smaller fixes and cleanup.
Diffstat (limited to 'examples/priority.c')
-rw-r--r--examples/priority.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/examples/priority.c b/examples/priority.c
index 780e5809..2d5c23bd 100644
--- a/examples/priority.c
+++ b/examples/priority.c
@@ -5,7 +5,7 @@
#include <stc/cmap.h>
#include <stc/crandom.h>
-declare_cvec(i, uint32_t);
+declare_cvec(i, int64_t);
declare_cvec_pqueue(i, >); // min-heap (increasing values)
int main() {
@@ -17,9 +17,16 @@ int main() {
for (int i=0; i<10000000; ++i)
cvec_i_pqueue_push(&heap, crandom_uniform_i32(&pcg, dist));
+ // push some negative numbers too.
+ c_push(&heap, cvec_i_pqueue, c_items(-231, -32, -873, -4, -343));
+
+ for (int i=0; i<10000000; ++i)
+ cvec_i_pqueue_push(&heap, crandom_uniform_i32(&pcg, dist));
+
+
// Extract the hundred smallest.
for (int i=0; i<100; ++i) {
- printf("%u ", cvec_i_pqueue_top(&heap));
+ printf("%d ", cvec_i_pqueue_top(&heap));
cvec_i_pqueue_pop(&heap);
}
cvec_i_destroy(&heap);