From 5a6bb1f5061a6ac75d70edf90f75dd976cfaba7d Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Fri, 2 Oct 2020 07:04:35 +0200 Subject: Fixed generic less function - only worked for int --- examples/heap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/heap.c b/examples/heap.c index bca5f2e7..cc8d1df1 100644 --- a/examples/heap.c +++ b/examples/heap.c @@ -18,13 +18,13 @@ int main() pcg = crand_rng32_init(seed); clock_t start = clock(); c_forrange (i, int, N) - cvec_f_push_back(&pq, (float) crand_i32(&pcg)); + cvec_f_push_back(&pq, (float) crand_f32(&pcg)*100000); cpqueue_f_make_heap(&pq); printf("Built priority queue: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC); c_forrange (i, int, M) - printf("%.0f ", *cpqueue_f_top(&pq)), cpqueue_f_pop(&pq); + printf("%g ", *cpqueue_f_top(&pq)), cpqueue_f_pop(&pq); start = clock(); c_forrange (i, int, M, N) @@ -34,11 +34,11 @@ int main() pcg = crand_rng32_init(seed); start = clock(); c_forrange (i, int, N) - cpqueue_f_push(&pq, (float) crand_i32(&pcg)); + cpqueue_f_push(&pq, (float) crand_f32(&pcg)*100000); printf("pushed PQ: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC); c_forrange (i, int, M) - printf("%.0f ", *cpqueue_f_top(&pq)), cpqueue_f_pop(&pq); + printf("%g ", *cpqueue_f_top(&pq)), cpqueue_f_pop(&pq); puts(""); cpqueue_f_del(&pq); -- cgit v1.2.3