diff options
| author | _Tradam <[email protected]> | 2023-09-08 01:29:47 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-09-08 01:29:47 +0000 |
| commit | 3c76c7f3d5db3f9586a90d03f8fbb02d79de9acd (patch) | |
| tree | afbe4b540967223911f7c5de36559b82154f02f3 /misc/examples/priority.c | |
| parent | 0841165881871ee01b782129be681209aeed2423 (diff) | |
| parent | 1a72205fe05c2375cfd380dd8381a8460d9ed8d1 (diff) | |
| download | STC-modified-modified.tar.gz STC-modified-modified.zip | |
Diffstat (limited to 'misc/examples/priority.c')
| -rw-r--r-- | misc/examples/priority.c | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/misc/examples/priority.c b/misc/examples/priority.c deleted file mode 100644 index 95dd3183..00000000 --- a/misc/examples/priority.c +++ /dev/null @@ -1,37 +0,0 @@ - -#include <stdio.h> -#include <time.h> -#include <stc/crand.h> - -#define i_val int64_t -#define i_cmp -c_default_cmp // min-heap (increasing values) -#define i_tag i -#include <stc/cpque.h> - -int main() { - intptr_t N = 10000000; - crand_t rng = crand_init((uint64_t)time(NULL)); - crand_unif_t dist = crand_unif_init(0, N * 10); - - cpque_i heap = {0}; - - // Push ten million random numbers to priority queue - printf("Push %" c_ZI " numbers\n", N); - c_forrange (N) - cpque_i_push(&heap, crand_unif(&rng, &dist)); - - // push some negative numbers too. - c_forlist (i, int, {-231, -32, -873, -4, -343}) - cpque_i_push(&heap, *i.ref); - - c_forrange (N) - cpque_i_push(&heap, crand_unif(&rng, &dist)); - - puts("Extract the hundred smallest."); - c_forrange (100) { - printf("%" PRId64 " ", *cpque_i_top(&heap)); - cpque_i_pop(&heap); - } - - cpque_i_drop(&heap); -} |
