initial commit
This commit is contained in:
41
test.c
Normal file
41
test.c
Normal file
@ -0,0 +1,41 @@
|
||||
#include "ds.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct complex {
|
||||
int num;
|
||||
char *str;
|
||||
};
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *a = "one";
|
||||
char *b = "two";
|
||||
ds_sll_t *ll = ds_sll_new_node(a); // [ "one" ]
|
||||
ds_sll_insert(ll, b); // [ "one", "two" ]
|
||||
ds_ll_foreach(ds_sll_t, ll) {
|
||||
puts(cur->data);
|
||||
}
|
||||
char *pa = ds_sll_remove(&ll, 0); // [ "two" ]
|
||||
char *pb = ds_sll_remove(&ll, 0); // [ ]
|
||||
|
||||
struct complex *a2 = calloc(1, sizeof(struct complex));
|
||||
a2->num = 1;
|
||||
a2->str = "abc";
|
||||
struct complex *b2 = calloc(1, sizeof(struct complex));
|
||||
b2->num = 2;
|
||||
b2->str = "def";
|
||||
|
||||
ds_hmp_t *hmp = ds_hmp_init(101);
|
||||
ds_hmp_insert(hmp, a2->str, a2); // [ (23)[ [ a->str, a ] ] ]
|
||||
ds_hmp_insert(hmp, b2->str, b2); // [ (23)[ [ a->str, a ] ], (58)[ [ b->str, b ] ]
|
||||
struct complex *pa2 = ds_hmp_remove(hmp, a2->str); // [ (23)[ [ a->str, a ] ]
|
||||
struct complex *pb2 = ds_hmp_remove(hmp, b2->str); // [ (58)[ [ b->str, b ] ]
|
||||
ds_hmp_free(&hmp);
|
||||
puts(pa2->str);
|
||||
puts(pb2->str);
|
||||
|
||||
free(pa2);
|
||||
free(pb2);
|
||||
}
|
Reference in New Issue
Block a user