ox

The Ox programming language, compiler and tools (WIP)
Log | Files | Refs | README | LICENSE

hmap.h (497B)



#pragma once

#include <stdbool.h>
#include <stdlib.h>

typedef struct HashNode {
	char* key;
	void* value;
	struct HashNode* next;
} HashNode;

typedef struct HashMap {
	size_t bucket_count;
	size_t size;
	size_t value_size;
	struct HashNode** buckets;
} HashMap;

HashMap* hmap_create(size_t);
void hmap_put(HashMap* map, const char* key, const void* value);
bool hmap_get(HashMap* map, const char* key, void* out);
bool hmap_remove(HashMap* map, const char* key);
void hmap_free(HashMap* map);