ox

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

hmap.h (497B)


      1 #pragma once
      2 
      3 #include <stdbool.h>
      4 #include <stdlib.h>
      5 
      6 typedef struct HashNode {
      7 	char* key;
      8 	void* value;
      9 	struct HashNode* next;
     10 } HashNode;
     11 
     12 typedef struct HashMap {
     13 	size_t bucket_count;
     14 	size_t size;
     15 	size_t value_size;
     16 	struct HashNode** buckets;
     17 } HashMap;
     18 
     19 HashMap* hmap_create(size_t);
     20 void hmap_put(HashMap* map, const char* key, const void* value);
     21 bool hmap_get(HashMap* map, const char* key, void* out);
     22 bool hmap_remove(HashMap* map, const char* key);
     23 void hmap_free(HashMap* map);