32 lines
751 B
C
Executable File
32 lines
751 B
C
Executable File
#pragma once
|
|
#include "../std.h"
|
|
#include "../string/str.h"
|
|
#include "Array.h"
|
|
#include "List.h"
|
|
|
|
typedef void (*FreeFunction)(void*);
|
|
|
|
typedef struct KeyHash {
|
|
str key;
|
|
u32 hash;
|
|
} KeyHash;
|
|
|
|
typedef struct HashMapBucket {
|
|
List key_hash_list;
|
|
List value_list;
|
|
} HashMapBucket;
|
|
|
|
typedef struct HashMap {
|
|
HashMapBucket* table;
|
|
FreeFunction NULLABLE(value_destructor);
|
|
u32 value_t_size;
|
|
u32 height;
|
|
u16 height_n;
|
|
} HashMap;
|
|
|
|
void HashMap_alloc(HashMap* ptr, u32 value_t_size, FreeFunction NULLABLE(value_destructor));
|
|
void HashMap_free(HashMap* ptr);
|
|
void* NULLABLE(HashMap_tryGetPtr)(HashMap* ptr, str key);
|
|
bool HashMap_tryPush(HashMap* ptr, str key, void* value_ptr);
|
|
bool HashMap_tryDelete(HashMap* ptr, str key);
|