This commit is contained in:
2023-02-11 12:19:05 +06:00
parent 609dfcf3ed
commit 305854e721
77 changed files with 565 additions and 562 deletions

View File

@@ -8,7 +8,7 @@ extern "C" {
#include "KeyValuePair.h"
typedef struct Hashtable{
uint8 hein; // height=HT_HEIGHTS[hein]
u8 hein; // height=HT_HEIGHTS[hein]
Autoarr(KVPair)** rows; // Autoarr[height]
} Hashtable;
ktid_declare(Hashtable);
@@ -18,7 +18,7 @@ void Hashtable_free(Hashtable* ht);
void __Hashtable_free(void* ht);
// amount of rows
uint16 Hashtable_height(Hashtable* ht);
u16 Hashtable_height(Hashtable* ht);
// don't add pairs with the same keys,
// or something weird will happen
@@ -34,8 +34,8 @@ Unitype Hashtable_get(Hashtable* ht, char* key);
bool Hashtable_try_get(Hashtable* ht, char* key, Unitype* output);
#define Hashtable_foreach(HT, EL, codeblock)({\
uint16 hmax=Hashtable_height(HT);\
for(uint16 h=0; h<hmax; h++){\
u16 hmax=Hashtable_height(HT);\
for(u16 h=0; h<hmax; h++){\
Autoarr(KVPair)* AR=HT->rows[h];\
Autoarr_foreach(AR, EL, codeblock);\
}\