Header file for a simple hash table implementation. More...
#include <stdbool.h>
Go to the source code of this file.
Classes | |
struct | Entry |
Represents an entry in the hash table. More... | |
struct | HashTable |
Represents the hash table. More... | |
Functions | |
unsigned int | hash (const char *key, int capacity) |
Computes the hash value for a given key. | |
HashTable * | table_create (int initial_capacity) |
Creates a new hash table with the specified initial capacity. | |
void | table_resize (HashTable *table) |
Resizes the hash table to accommodate more entries. | |
Entry * | table_insert (HashTable *table, const char *key, void *value) |
Inserts a key-value pair into the hash table. | |
void | table_insert_raw (HashTable *table, const char *key, void *value) |
Inserts a key-value pair into the hash table without checking for duplicates. | |
void * | table_get (HashTable *table, const char *key) |
Retrieves the value associated with a given key in the hash table. | |
void | table_remove (HashTable *table, const char *key) |
Removes a key-value pair from the hash table. | |
void | table_free (HashTable *table) |
Frees all memory associated with the hash table. | |
Header file for a simple hash table implementation.
This file contains the definitions and function declarations for a hash table implementation that supports insertion, retrieval, and deletion of key-value pairs.
unsigned int hash | ( | const char * | key, |
int | capacity | ||
) |
Computes the hash value for a given key.
key | The key to hash. |
capacity | The capacity of the hash table. |
HashTable * table_create | ( | int | initial_capacity | ) |
Creates a new hash table with the specified initial capacity.
initial_capacity | The initial capacity of the hash table. |
void table_resize | ( | HashTable * | table | ) |
Resizes the hash table to accommodate more entries.
table | The hash table to resize. |
Inserts a key-value pair into the hash table.
table | The hash table. |
key | The key to insert. |
value | The value to associate with the key. |
void table_insert_raw | ( | HashTable * | table, |
const char * | key, | ||
void * | value | ||
) |
Inserts a key-value pair into the hash table without checking for duplicates.
table | The hash table. |
key | The key to insert. |
value | The value to associate with the key. |
void * table_get | ( | HashTable * | table, |
const char * | key | ||
) |
Retrieves the value associated with a given key in the hash table.
table | The hash table. |
key | The key to look up. |
void table_remove | ( | HashTable * | table, |
const char * | key | ||
) |
Removes a key-value pair from the hash table.
table | The hash table. |
key | The key to remove. |
void table_free | ( | HashTable * | table | ) |
Frees all memory associated with the hash table.
table | The hash table to free. |