/* * Tiny hashmap implementation. * Copyright (c) 2023-2024, Quinn Stephens and the OSMORA team. * Provided under the BSD 3-Clause license. */ #ifndef _HASHMAP_H #define _HASHMAP_H #include #include "list.h" #include "hash.h" struct hashmap_entry { struct list_entry list_entry; hash_t hash; }; struct hashmap { struct list *rows; size_t n_rows; }; static inline void hashmap_remove(struct hashmap_entry *entry) { list_remove(&entry->list_entry); } void hashmap_add(struct hashmap *map, struct hashmap_entry *entry); struct hashmap_entry *hashmap_find(struct hashmap *map, hash_t hash); void hashmap_free_entries(struct hashmap *map); void hashmap_init(struct hashmap *map); #endif /* !_HASHMAP_H */