feat(queue): introduce a queue ds, internally this is just a stack...

the only actual difference is a oneline change which makes pushing
append instead of prepend the new data.
This commit is contained in:
Squibid 2025-11-17 17:51:57 -05:00
parent 9daffd4ed1
commit 758edf9d30
Signed by: squibid
GPG key ID: BECE5684D3C4005D
4 changed files with 93 additions and 1 deletions

21
test.c
View file

@ -99,4 +99,25 @@ main(int argc, char *argv[])
free(stack);
);
test("queue",
char *a = "a";
char *b = "b";
char *c = "c";
ds_queue_t *queue = ds_queue_init();
it("pushes an item", ds_queue_push(queue, a) == 0);
it("pops an item", ds_queue_pop(queue) == a);
ds_queue_push(queue, b);
ds_queue_push(queue, c);
it("peeks ahead", ds_queue_peek(queue, 0) == b);
it("peeks past the queue", ds_queue_peek(queue, INT_MAX) == NULL);
ds_queue_pop(queue);
ds_queue_pop(queue);
free(queue);
);
}