feat(stack): introduce a stack ds, internally this uses a sll
This commit is contained in:
parent
69dc1dcb45
commit
945343daa0
4 changed files with 127 additions and 0 deletions
14
README.md
14
README.md
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue