// Kyler Olsen // YREA SLS // Hash Table Header // November 2025 #ifndef SLS_HASH_TABLE_H #define SLS_HASH_TABLE_H #include #include "sls/string.h" typedef struct Bucket { uint32_t hash_a; uint32_t hash_b; void *item; struct Bucket *next; } Bucket; typedef struct { size_t buckets_count; Bucket *buckets[]; } HashTable; // Initializes a HashTable with atleast buckets_count number of buckets. Returns NULL on Memory Allocation Error. HashTable *init_hash_table(size_t min_buckets_count); // Frees memory owned by the HashTable. void del_hash_table(HashTable *ht); // Inserts an item into the HashTable based on its key. Returns FALSE on Memory Allocation Error. Boolean hash_table_put(HashTable *ht, SlsStr key, void *item); // Gets the item associated with the given key. Returns default item if not found. void *hash_table_get(const HashTable *ht, SlsStr key, void *default_item); // Deletes the item associated with the given key. Returns FALSE if item is not found. Boolean hash_table_del(HashTable *ht, SlsStr key); #endif // SLS_HASH_TABLE_H