summaryrefslogtreecommitdiffhomepage
path: root/examples/queue.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-06-01 16:28:07 +0200
committerTyge Løvset <[email protected]>2022-06-01 16:28:07 +0200
commitde629774cb912aa3d563f24d99258142713c3fcd (patch)
treec37e2851d6cb049bc0863a59b6ecf5945fb88619 /examples/queue.c
parent7fb43a24a17da787dd809114ca26c1231b058493 (diff)
downloadSTC-modified-de629774cb912aa3d563f24d99258142713c3fcd.tar.gz
STC-modified-de629774cb912aa3d563f24d99258142713c3fcd.zip
Converted all files with DOS line endings to LINUX.
Diffstat (limited to 'examples/queue.c')
-rw-r--r--examples/queue.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/examples/queue.c b/examples/queue.c
index 1b56d96a..57e24fe6 100644
--- a/examples/queue.c
+++ b/examples/queue.c
@@ -1,32 +1,32 @@
-#define i_implement
-#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, %" PRIuMAX "\n", n, cqueue_i_size(queue));
- }
-}
+#define i_implement
+#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, %" PRIuMAX "\n", n, cqueue_i_size(queue));
+ }
+}