diff options
| author | tylov <[email protected]> | 2023-07-20 15:09:10 +0200 |
|---|---|---|
| committer | tylov <[email protected]> | 2023-07-20 15:12:29 +0200 |
| commit | 900295256d825fc323149cd223c49787f32a3696 (patch) | |
| tree | 6c79cf4209e3975bb6865e2940b9cb56ea469c73 /misc/examples/queue.c | |
| parent | 224a04f7fa7549ed94d2a1415eb25829e39a7cca (diff) | |
| download | STC-modified-900295256d825fc323149cd223c49787f32a3696.tar.gz STC-modified-900295256d825fc323149cd223c49787f32a3696.zip | |
Moved examples to sub-directories. Added cotask1.c cotask2.c examples.
Diffstat (limited to 'misc/examples/queue.c')
| -rw-r--r-- | misc/examples/queue.c | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/misc/examples/queue.c b/misc/examples/queue.c deleted file mode 100644 index 56b5beb9..00000000 --- a/misc/examples/queue.c +++ /dev/null @@ -1,32 +0,0 @@ -#include <stc/crand.h> -#include <stdio.h> - -#define i_key int -#define i_tag i -#include <stc/cqueue.h> - -int main(void) { - int n = 100000000; - crand_unif_t dist; - crand_t rng = crand_init(1234); - dist = crand_unif_init(0, n); - - cqueue_i queue = {0}; - - // Push ten million random numbers onto the queue. - c_forrange (n) - cqueue_i_push(&queue, (int)crand_unif(&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 = (int)crand_unif(&rng, &dist); - if (r & 1) - ++n, cqueue_i_push(&queue, r); - else - --n, cqueue_i_pop(&queue); - } - printf("%d, %" c_ZI "\n", n, cqueue_i_size(&queue)); - - cqueue_i_drop(&queue); -} |
