feat(README): update the readme
This commit is contained in:
17
README.md
17
README.md
@@ -7,7 +7,8 @@ Example of working with a singly linked list (sll):
|
||||
```c
|
||||
char *a = "one";
|
||||
char *b = "two";
|
||||
ds_sll_t *ll = ds_sll_new_node(a); // [ "one" ]
|
||||
ds_sll_t *ll = ds_sll_init();
|
||||
ds_sll_insert(ll, a); // [ "one" ]
|
||||
ds_sll_insert(ll, b); // [ "one", "two" ]
|
||||
ds_ll_foreach(ds_sll_t, ll) {
|
||||
puts(cur->data);
|
||||
@@ -22,28 +23,28 @@ datatypes.
|
||||
|
||||
## Hash Map
|
||||
```c
|
||||
struct complex {
|
||||
typedef struct {
|
||||
int num;
|
||||
char *str;
|
||||
};
|
||||
} complex ;
|
||||
|
||||
struct complex *a = calloc(1, sizeof(struct complex));
|
||||
complex *a = calloc(1, sizeof(complex));
|
||||
a->num = 1;
|
||||
a->str = "abc";
|
||||
struct complex *b = calloc(1, sizeof(struct complex));
|
||||
complex *b = calloc(1, sizeof(complex));
|
||||
b->num = 2;
|
||||
b->str = "def";
|
||||
|
||||
ds_hmp_t *hmp = ds_hmp_init(101);
|
||||
ds_hmp_insert(hmp, a->str, a); // [ (23)[ [ a->str, a ] ] ]
|
||||
ds_hmp_insert(hmp, b->str, b); // [ (23)[ [ a->str, a ] ], (58)[ [ b->str, b ] ]
|
||||
struct complex *pa = ds_hmp_remove(hmp, a->str); // a
|
||||
complex *pa = ds_hmp_remove(hmp, a->str); // a
|
||||
free(pa->str);
|
||||
free(pa);
|
||||
ds_hmp_free(&hmp);
|
||||
ds_hmp_free(&hmp, NULL);
|
||||
free(b);
|
||||
```
|
||||
|
||||
# TODO
|
||||
- [ ] more data structures
|
||||
- [ ] tests
|
||||
- [x] tests
|
||||
|
Reference in New Issue
Block a user