summaryrefslogtreecommitdiffhomepage
path: root/examples/queue.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-09-13 11:43:18 +0200
committerTyge Løvset <[email protected]>2020-09-13 11:43:18 +0200
commitb3a1581b7dabd0fe8989f605bdcf1fee93f657d9 (patch)
treec006823101255063ff597fbc9e3dc5a0ee0ad7cf /examples/queue.c
parent53b89639a8d00af879389b55edb29276dd31e0db (diff)
downloadSTC-modified-b3a1581b7dabd0fe8989f605bdcf1fee93f657d9.tar.gz
STC-modified-b3a1581b7dabd0fe8989f605bdcf1fee93f657d9.zip
reverted back to separate random engine and distribution parameters.
Diffstat (limited to 'examples/queue.c')
-rw-r--r--examples/queue.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/queue.c b/examples/queue.c
index 15897f38..25aefd09 100644
--- a/examples/queue.c
+++ b/examples/queue.c
@@ -8,18 +8,19 @@ declare_cqueue(i, clist_i); // min-heap (increasing values)
int main() {
int n = 10000000;
crand_uniform_i32_t dist;
- dist = crand_uniform_i32_init(crand_rng32_init(1234), 0, n);
+ crand_rng32_t rng = crand_rng32_init(1234);
+ dist = crand_uniform_i32_init(0, n);
cqueue_i queue = cqueue_i_init();
// Push ten million random numbers onto the queue.
for (int i=0; i<n; ++i)
- cqueue_i_push(&queue, crand_uniform_i32(&dist));
+ cqueue_i_push(&queue, crand_uniform_i32(&rng, &dist));
// Push or pop on the queue ten million times
printf("%d\n", n);
for (int i=n; i>0; --i) {
- int r = crand_uniform_i32(&dist);
+ int r = crand_uniform_i32(&rng, &dist);
if (r & 1)
++n, cqueue_i_push(&queue, r);
else