Parser_parseOperation
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "../std.h"
|
||||
#include "../string/str.h"
|
||||
#include "Array.h"
|
||||
#include "List.h"
|
||||
|
||||
//TODO: sorting of bucket and binary search
|
||||
//TODO: delayed deletion
|
||||
@@ -34,7 +35,7 @@ typedef struct HashMap_##T {\
|
||||
\
|
||||
void HashMap_##T##_alloc(HashMap_##T* ptr);\
|
||||
void HashMap_##T##_free(HashMap_##T* ptr);\
|
||||
NULLABLE(T*) HashMap_##T##_tryGetPtr(HashMap_##T* ptr, str key);\
|
||||
T* NULLABLE(HashMap_##T##_tryGetPtr)(HashMap_##T* ptr, str key);\
|
||||
bool HashMap_##T##_tryPush(HashMap_##T* ptr, str key, T value);\
|
||||
bool HashMap_##T##_tryDelete(HashMap_##T* ptr, str key);\
|
||||
|
||||
@@ -75,7 +76,7 @@ void HashMap_##T##_free(HashMap_##T* ptr){\
|
||||
free(ptr->table);\
|
||||
}\
|
||||
\
|
||||
NULLABLE(T*) HashMap_##T##_tryGetPtr(HashMap_##T* ptr, str key){\
|
||||
T* NULLABLE(HashMap_##T##_tryGetPtr)(HashMap_##T* ptr, str key){\
|
||||
u32 hash = __HashMap_HASH_FUNC(key);\
|
||||
HashMapBucket_##T* bu = &ptr->table[hash % ptr->height];\
|
||||
for(u32 i = 0; i < bu->kvs.len; i++){\
|
||||
@@ -98,7 +99,7 @@ bool HashMap_##T##_tryPush(HashMap_##T* ptr, str key, T value){\
|
||||
\
|
||||
if(bu->kvs.len >= __HashMapBucket_MAX_LEN){\
|
||||
u32 height_expanded_n = ptr->height_n + 1;\
|
||||
if(height_expanded_n >= __HashMap_u32_heights.len){\
|
||||
if(height_expanded_n >= __HashMap_##T##_heights.len){\
|
||||
printf("ERROR: HashMap_" #T " IS FULL\n");\
|
||||
return false;\
|
||||
}\
|
||||
|
||||
Reference in New Issue
Block a user