diff options
| author | Tyge Løvset <[email protected]> | 2020-12-31 15:38:09 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-12-31 15:38:09 +0100 |
| commit | 728cece1c43a494729e21818fdaa321af29788d2 (patch) | |
| tree | cb16c31505d8ac72d68baa6655ca4ec1acc04e51 /docs/cqueue_api.md | |
| parent | fedc9d03dc5867bd395f49f57c6ef320952008bf (diff) | |
| download | STC-modified-728cece1c43a494729e21818fdaa321af29788d2.tar.gz STC-modified-728cece1c43a494729e21818fdaa321af29788d2.zip | |
Update cqueue_api.md
Diffstat (limited to 'docs/cqueue_api.md')
| -rw-r--r-- | docs/cqueue_api.md | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/docs/cqueue_api.md b/docs/cqueue_api.md index 8a6edd2b..f51b78c3 100644 --- a/docs/cqueue_api.md +++ b/docs/cqueue_api.md @@ -81,4 +81,33 @@ int main() { Output: ``` 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 -```
\ No newline at end of file +``` +### Example 2 +```c +#include <stdio.h> +#include "stc/cqueue.h" +#include "stc/cdeq.h" + +using_cdeq(i, int); +using_cqueue(i, cdeq_i); + +int main() { + cqueue_i queue = cqueue_i_init(); + + // push() and pop() a few. + c_forrange (i, 20) + cqueue_i_push(&queue, i); + + c_forrange (5) + cqueue_i_pop(&queue); + + c_foreach (i, cqueue_i, queue) + printf(" %d", *i.ref); + + cqueue_i_del(&queue); +} +``` +Output: +``` +5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 +``` |
