diff options
| author | Tyge Løvset <[email protected]> | 2020-08-30 00:37:49 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-08-30 00:43:32 +0200 |
| commit | d9c68300a49bc07d52463bb4874f14ce1efce49d (patch) | |
| tree | 15b53a2948114480067639e5ae76d4f32f498af8 /examples | |
| parent | c15b39eed1f7041b1fb84a72da4e4e0fae1318a8 (diff) | |
| download | STC-modified-d9c68300a49bc07d52463bb4874f14ce1efce49d.tar.gz STC-modified-d9c68300a49bc07d52463bb4874f14ce1efce49d.zip | |
Minors added.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/priority.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/examples/priority.c b/examples/priority.c index 598f448a..7dfff7da 100644 --- a/examples/priority.c +++ b/examples/priority.c @@ -9,24 +9,25 @@ declare_cvec(i, int64_t); declare_cvec_pqueue(i, >); // min-heap (increasing values)
int main() {
- crand_rng32_t pcg = crand_rng32_init(time(NULL));
- crand_uniform_i32_t dist = crand_uniform_i32_init(pcg, 0, 100000000);
+ size_t N = 100000000;
+ crand_rng64_t pcg = crand_rng64_init(time(NULL));
+ crand_uniform_i64_t dist = crand_uniform_i64_init(pcg, 0, N * 10);
cvec_i heap = cvec_init;
// Push ten million random numbers to priority queue
- for (int i=0; i<10000000; ++i)
- cvec_i_pqueue_push(&heap, crand_uniform_i32(&dist));
+ for (int i=0; i<N; ++i)
+ cvec_i_pqueue_push(&heap, crand_uniform_i64(&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, crand_uniform_i32(&dist));
+ for (int i=0; i<N; ++i)
+ cvec_i_pqueue_push(&heap, crand_uniform_i64(&dist));
// Extract the hundred smallest.
for (int i=0; i<100; ++i) {
- printf("%d ", cvec_i_pqueue_top(&heap));
+ printf("%zd ", cvec_i_pqueue_top(&heap));
cvec_i_pqueue_pop(&heap);
}
cvec_i_destroy(&heap);
|
