37 lines
712 B
C
37 lines
712 B
C
#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;
|
|
|
|
bool hashtable_recreate(hashtable* table);
|
|
|
|
hashtable* hashtable_create(void);
|
|
|
|
void hashtable_destroy(hashtable*);
|
|
|
|
size_t_optional hashtable_key(hashtable*, char*);
|
|
|
|
size_t_optional hashtable_insert(hashtable*, char*);
|
|
|
|
void* hashtable_get(hashtable* table, char* name);
|
|
|
|
void hashtable_set(hashtable* table, char* name, void* data);
|
|
|
|
bool hashtable_delete(hashtable*, char*);
|
|
|
|
void hashtable_forall(hashtable*, void (*)(char*, void*, void*), void*);
|