2024-06-28 22:37:51 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
bool exists;
|
|
|
|
size_t sizet;
|
|
|
|
} size_t_optional;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char* name;
|
|
|
|
void* data;
|
|
|
|
} hashtable_item;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
size_t capacity;
|
|
|
|
size_t filled;
|
|
|
|
hashtable_item* items;
|
|
|
|
} hashtable;
|
|
|
|
|
2024-07-28 20:22:58 +00:00
|
|
|
bool hashtable_recreate(hashtable* table);
|
|
|
|
|
2024-06-28 22:37:51 +00:00
|
|
|
hashtable* hashtable_create(void);
|
|
|
|
|
|
|
|
void hashtable_destroy(hashtable*);
|
|
|
|
|
|
|
|
size_t_optional hashtable_key(hashtable*, char*);
|
|
|
|
|
2024-07-28 19:57:08 +00:00
|
|
|
size_t_optional hashtable_insert(hashtable*, char*);
|
2024-06-28 22:37:51 +00:00
|
|
|
|
|
|
|
void* hashtable_get(hashtable* table, char* name);
|
|
|
|
|
|
|
|
void hashtable_set(hashtable* table, char* name, void* data);
|
2024-07-28 19:57:08 +00:00
|
|
|
|
2024-07-28 20:22:58 +00:00
|
|
|
bool hashtable_delete(hashtable*, char*);
|
2024-07-28 19:57:08 +00:00
|
|
|
|
|
|
|
void hashtable_forall(hashtable*, void (*)(char*, void*));
|