2023-02-20 15:19:58 +00:00
|
|
|
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#define TABLE_MAX_LOAD 0.75
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
const char* key;
|
|
|
|
long value;
|
|
|
|
} Entry;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int len;
|
|
|
|
int capacity;
|
|
|
|
Entry* entries;
|
|
|
|
} Hashmap;
|
|
|
|
|
|
|
|
void hashmap_init(Hashmap* hashmap);
|
|
|
|
void hashmap_free(Hashmap* hashmap);
|
|
|
|
|
2023-02-23 16:43:57 +00:00
|
|
|
bool hashmap_add(Hashmap* hashmap, const char* key, long value);
|
2023-02-20 15:19:58 +00:00
|
|
|
bool hashmap_get(Hashmap* hashmap, const char* key, long* value);
|
|
|
|
bool hashmap_remove(Hashmap* hashmap, const char* key);
|
|
|
|
|