summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-07-19 22:55:40 +0200
committerTyge Løvset <[email protected]>2020-07-19 22:55:40 +0200
commit741632132ddbd1c5797b85998e08c80208d53f7d (patch)
treee8f59b99d5841dad3d2e1a8678da0eb1f266fe2e
parent336a91e14c97f9f9a9cd097bf8fa328b5c3c2715 (diff)
downloadSTC-modified-741632132ddbd1c5797b85998e08c80208d53f7d.tar.gz
STC-modified-741632132ddbd1c5797b85998e08c80208d53f7d.zip
Fixed example.
-rw-r--r--stc/cvecpq.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/stc/cvecpq.h b/stc/cvecpq.h
index 40d2603b..a6134620 100644
--- a/stc/cvecpq.h
+++ b/stc/cvecpq.h
@@ -30,11 +30,15 @@
int main() {
pcg32_random_t pcg = pcg32_seed(1234, 0);
CVec_i heap = cvec_init;
- for (int i=0; i<100; ++i) cvec_i_pushPriorityQ(&heap, pcg32_random(&pcg));
- for (int i=0; i<5; ++i) {
- printf("%d ", cvec_i_topPriorityQ(&heap, pcg32_random(&pcg)));
- cvec_i_popPriorityQ(&heap, pcg32_random(&pcg));
+ // Push on one million random numbers
+ for (int i=0; i<1000000; ++i)
+ cvec_i_pushPriorityQ(&heap, pcg32_random(&pcg));
+ // Extract the 100 smallest.
+ for (int i=0; i<100; ++i) {
+ printf("%d ", cvec_i_topPriorityQ(&heap));
+ cvec_i_popPriorityQ(&heap);
}
+ cvec_i_destroy(&heap);
}
*/