feat(stack): introduce a stack ds, internally this uses a sll

This commit is contained in:
Squibid 2025-11-15 21:47:45 -05:00
parent 69dc1dcb45
commit 945343daa0
Signed by: squibid
GPG key ID: BECE5684D3C4005D
4 changed files with 127 additions and 0 deletions

View file

@ -45,6 +45,20 @@ ds_hmp_free(&hmp, NULL);
free(b);
```
## Stack
```c
char *a = "a";
char *b = "b";
ds_stack_t *stack = ds_stack_init();
ds_stack_push(stack, a); // [ "a" ]
ds_stack_push(stack, b); // [ "b", "a" ]
ds_stack_peek(stack, 0); // "b"
ds_stack_pop(stack); // "b"
ds_stack_pop(stack); // "a"
free(stack);
```
# TODO
- [ ] more data structures
- [x] tests