hash/hashtable.h

43 lines
823 B
C

#include <stdlib.h>
#include <stdbool.h>
#ifndef HASHTABLE_H
#define HASHTABLE_H
typedef struct {
bool exists;
size_t sizet;
} size_t_optional;
typedef struct {
size_t size;
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);
size_t_optional hashtable_insert(hashtable*, char*, size_t);
void* hashtable_get(hashtable* table, char* name, size_t);
void hashtable_set(hashtable* table, char* name, size_t, void* data);
bool hashtable_delete(hashtable*, char*, size_t);
void hashtable_forall(hashtable*, void (*)(char*, size_t, void*, void*), void*);
#endif