diff options
| author | Mistivia <i@mistivia.com> | 2024-01-27 14:28:51 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2024-01-27 14:28:51 +0800 |
| commit | 087a111b3417cbda03a3453b3d16dd4d1cf54a9e (patch) | |
| tree | 000a15054865c3fb974970238568bb1d81a3f29e /advent-of-code/2022/lib/htable.h | |
| parent | 203658f4a5b8649d0142ab8ff6440eb0eefa48e9 (diff) | |
add aoc 2022
Diffstat (limited to 'advent-of-code/2022/lib/htable.h')
| -rw-r--r-- | advent-of-code/2022/lib/htable.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/advent-of-code/2022/lib/htable.h b/advent-of-code/2022/lib/htable.h new file mode 100644 index 0000000..3bde74f --- /dev/null +++ b/advent-of-code/2022/lib/htable.h @@ -0,0 +1,29 @@ +#ifndef HTABLE_H_ +#define HTABLE_H_ + +#include <stdbool.h> +#include <stdint.h> + +typedef struct { + void *buf; + int size; + int cap; + int taken; + void* begin; + int elemsz; + uint32_t (*hash)(void*); + bool (*eq)(void*, void*); +} HTable; + +void htable_init(HTable *ht, int elemsz, int cap, uint32_t (*hash)(void*), + bool (*eq)(void*, void*)); +bool htable_insert(HTable *ht, void* elem); +void htable_del(HTable *ht, void* iter); + +// return a iterator +void* htable_find(HTable *ht, void* elem); +void* htable_begin(HTable *ht); +void* htable_next(HTable *ht, void *iter); + +#endif + |
