summaryrefslogtreecommitdiffhomepage
path: root/examples/queue.c
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2022-12-20 23:31:51 +0100
committerTyge Lovset <[email protected]>2022-12-20 23:31:51 +0100
commit5f57d597cd27aef55adbcb3b452973b0c6e33667 (patch)
treedfd59c2fd0e36a6ef37912a9d0cc5a65970f1524 /examples/queue.c
parent1763be8c8cbbc0896477fcf924edd4180d1345a9 (diff)
downloadSTC-modified-5f57d597cd27aef55adbcb3b452973b0c6e33667.tar.gz
STC-modified-5f57d597cd27aef55adbcb3b452973b0c6e33667.zip
Restructured folders: examples, benchmarks, tests into misc folder.
Diffstat (limited to 'examples/queue.c')
-rw-r--r--examples/queue.c31
1 files changed, 0 insertions, 31 deletions
diff --git a/examples/queue.c b/examples/queue.c
deleted file mode 100644
index f39c4b8b..00000000
--- a/examples/queue.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <stc/crandom.h>
-#include <stdio.h>
-
-#define i_val int
-#define i_tag i
-#include <stc/cqueue.h>
-
-int main() {
- int n = 100000000;
- stc64_uniform_t dist;
- stc64_t rng = stc64_new(1234);
- dist = stc64_uniform_new(0, n);
-
- c_auto (cqueue_i, queue)
- {
- // Push ten million random numbers onto the queue.
- c_forrange (n)
- cqueue_i_push(&queue, stc64_uniform(&rng, &dist));
-
- // Push or pop on the queue ten million times
- printf("%d\n", n);
- c_forrange (n) { // forrange uses initial n only.
- int r = stc64_uniform(&rng, &dist);
- if (r & 1)
- ++n, cqueue_i_push(&queue, r);
- else
- --n, cqueue_i_pop(&queue);
- }
- printf("%d, %" c_ZU "\n", n, cqueue_i_size(&queue));
- }
-}