diff options
| author | Mosder <xmosder12@gmail.com> | 2026-07-10 16:31:08 +0200 |
|---|---|---|
| committer | Mosder <xmosder12@gmail.com> | 2026-07-10 16:31:08 +0200 |
| commit | f75a39e4c476c266efff6cff44d03d6afff3a4f7 (patch) | |
| tree | fd95845b2dd935bfeb49bc93ef9e6868629b62bd | |
| parent | 26d8457a5da5d70226fdbba5ed92fda8cac735f6 (diff) | |
refactor: moved hashmap implementation from utils to new directory utils/structures and removed unnecessary functionality from it
| -rw-r--r-- | analyzer/utils/structures/hashmap.c (renamed from analyzer/utils/hashmap.c) | 38 | ||||
| -rw-r--r-- | analyzer/utils/structures/hashmap.h (renamed from analyzer/utils/hashmap.h) | 21 |
2 files changed, 0 insertions, 59 deletions
diff --git a/analyzer/utils/hashmap.c b/analyzer/utils/structures/hashmap.c index 2ab8bab..466f258 100644 --- a/analyzer/utils/hashmap.c +++ b/analyzer/utils/structures/hashmap.c @@ -96,27 +96,6 @@ void hashmap_delete(HashMap *map, void *key) { } } -HashMapNode *hashmap_first(HashMap *map) { - for (size_t i = 0; i < HASHMAP_TABLE_SIZE; i++) { - HashMapNode *node = map->table[i]; - if (node) - return node; - } - return NULL; -} - -HashMapNode *hashmap_next(HashMap *map, HashMapNode *node) { - if (node->next) - return node->next; - - for (size_t i = map->hash(node->key) + 1; i < HASHMAP_TABLE_SIZE; i++) { - HashMapNode *node = map->table[i]; - if (node) - return node; - } - return NULL; -} - void hashmap_free(HashMap *map) { for (size_t i = 0; i < HASHMAP_TABLE_SIZE; i++) { HashMapNode *curr = map->table[i]; @@ -128,20 +107,3 @@ void hashmap_free(HashMap *map) { } free(map); } - -size_t hash_uint32(void *key) { - // MurmurHash3 - uint32_t k = *(uint32_t *)key; - k ^= k >> 16; - k *= 0x85ebca6b; - k ^= k >> 13; - k *= 0xc2b2ae35; - k ^= k >> 16; - return k % HASHMAP_TABLE_SIZE; -} - -int compare_uint32(void *key1, void *key2) { - uint32_t *k1 = key1; - uint32_t *k2 = key2; - return *k1 == *k2; -} diff --git a/analyzer/utils/hashmap.h b/analyzer/utils/structures/hashmap.h index 22c71c6..cc2c9e0 100644 --- a/analyzer/utils/hashmap.h +++ b/analyzer/utils/structures/hashmap.h @@ -72,27 +72,6 @@ extern void *hashmap_get(HashMap *map, void *key); // - key - pointer to the key of the entry to delete extern void hashmap_delete(HashMap *map, void *key); -// get first node in the hashmap, use with hashmap_next to iterate over hashmap -// params: -// - map - hash map to get the first node from -// returns: -// pointer to the first node in the hashmap or NULL if there's no entries in it -extern HashMapNode *hashmap_first(HashMap *map); - -// get next node in the hashmap, use with hashmap_first to iterate over hashmap -// params: -// - map - hash map to get the next node from -// - node - the node preceeding the one we search for -// returns: -// pointer to the next node in the hashmap or NULL if there's no next -extern HashMapNode *hashmap_next(HashMap *map, HashMapNode *node); - // free the hash map // - map - hash map to free extern void hashmap_free(HashMap *map); - -// hash uint32_t key -extern size_t hash_uint32(void *key); - -// compare uint32_t keys -extern int compare_uint32(void *key1, void *key2); |
