diff options
| author | 2024-01-31 18:55:24 -0600 | |
|---|---|---|
| committer | 2024-01-31 18:55:24 -0600 | |
| commit | 470b35047e515fc7a48be54d7199152487709fb5 (patch) | |
| tree | 6d114e3ef855fe00d56741b65ed56c4e466524cc /src/libmain.c | |
| parent | indentation tabs to spaces (diff) | |
finish hash implementation (untested)
Diffstat (limited to 'src/libmain.c')
| -rw-r--r-- | src/libmain.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/libmain.c b/src/libmain.c index a7b1e8b..25a340d 100644 --- a/src/libmain.c +++ b/src/libmain.c @@ -9,26 +9,18 @@ #if 1 int main(int argc, char **argv) { - shash_t *hash = shash_create(8, 0.75f); - printf("%d\n", shash_put(hash, "test1", "test2")); - printf("%d\n", shash_put(hash, "abc", "def")); + shash_t *hash = shash_create(4, 0.75f); + printf("%d\n", shash_put(hash, "test1", "value1")); + printf("%d\n", shash_put(hash, "testbro", "val2")); shash__debug_table(hash); - printf("%d\n", shash_put(hash, "amingus", "val")); - printf("%d\n", shash_put(hash, "afungus", "val2")); - printf("%d\n", shash_put(hash, "abungus", "val3")); - shash__debug_table(hash); - printf("%d\n", shash_put(hash, "lethalbumpany", "crewmate_sus")); - shash__debug_table(hash); - printf("%d\n", shash_put(hash, "uuuu", "something")); - printf("%d\n", shash_put(hash, "afungus", "val2")); - shash__debug_table(hash); - printf("%d\n", shash_put(hash, "99asdas", "please collide >:O")); - bool found = false; - char *val = shash_getn(hash, "99asdas", 0, &found); - printf("%s %d\n", val ? val : "(null)", found); + char *oldval = shash_pop(hash, "test1", NULL); + printf("%s:%s\n", "test1", oldval); + free(oldval); shash__debug_table(hash); + printf("%d\n", shash_put(hash, "testbro", "val3")); + shash__debug_table(hash); shash_free(hash); |
