From 728cece1c43a494729e21818fdaa321af29788d2 Mon Sep 17 00:00:00 2001 From: Tyge Løvset <60263450+tylov@users.noreply.github.com> Date: Thu, 31 Dec 2020 15:38:09 +0100 Subject: Update cqueue_api.md --- docs/cqueue_api.md | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) 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 +#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 +``` -- cgit v1.2.3