diff options
| author | Tyge Løvset <[email protected]> | 2020-07-23 20:35:07 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-07-23 20:35:07 +0200 |
| commit | 1c686f72bf9857c904b1320df7248ee5144d484e (patch) | |
| tree | 112754382836a80450da6bd0ed2c24aa48fc23fb /examples/priority.c | |
| parent | c6fdaca5aea99cc7e57661c1637101a78d01ba86 (diff) | |
| download | STC-modified-1c686f72bf9857c904b1320df7248ee5144d484e.tar.gz STC-modified-1c686f72bf9857c904b1320df7248ee5144d484e.zip | |
Changed cvecpq.h priority queue API and crandom.h API
Diffstat (limited to 'examples/priority.c')
| -rw-r--r-- | examples/priority.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/priority.c b/examples/priority.c index d6168a6b..4032b19c 100644 --- a/examples/priority.c +++ b/examples/priority.c @@ -6,21 +6,21 @@ #include <stc/crandom.h>
declare_CVec(i, uint32_t);
-declare_CVec_priorityQ(i, >); // min-heap (increasing values)
+declare_CVec_priority_queue(i, >); // min-heap (increasing values)
declare_CMap(ii, int, int);
int main() {
- pcg32_random_t pcg = pcg32_seed(time(NULL), 0);
+ crandom32_t pcg = crandom32_init(time(NULL));
CVec_i heap = cvec_init;
// Push ten million random numbers to queue
for (int i=0; i<10000000; ++i)
- cvec_i_pushPriorityQ(&heap, pcg32_random(&pcg));
+ cvecpq_i_push(&heap, crandom32(&pcg));
// Extract the hundred smallest.
for (int i=0; i<100; ++i) {
- printf("%u ", cvec_i_topPriorityQ(&heap));
- cvec_i_popPriorityQ(&heap);
+ printf("%u ", cvecpq_i_top(&heap));
+ cvecpq_i_pop(&heap);
}
cvec_i_destroy(&heap);
}
\ No newline at end of file |
