renamed sosme HashMap methods
This commit is contained in:
parent
51980ebb0b
commit
03bebea4b2
@ -26,9 +26,8 @@ typedef struct HashMap_ {
|
|||||||
u16 height_n;
|
u16 height_n;
|
||||||
} HashMap_;
|
} HashMap_;
|
||||||
|
|
||||||
//TODO: standartize constructor function names across tlibc
|
#define HashMap_construct(PTR, T, VALUE_DESTRUCTOR) HashMap_construct_size(PTR, sizeof(T), VALUE_DESTRUCTOR)
|
||||||
#define HashMap_create(PTR, T, VALUE_DESTRUCTOR) HashMap_create_size(PTR, sizeof(T), VALUE_DESTRUCTOR)
|
void HashMap_construct_size(HashMap_* ptr, u32 value_t_size, FreeFunction NULLABLE(value_destructor));
|
||||||
void HashMap_create_size(HashMap_* ptr, u32 value_t_size, FreeFunction NULLABLE(value_destructor));
|
|
||||||
void HashMap_destroy(HashMap_* ptr);
|
void HashMap_destroy(HashMap_* ptr);
|
||||||
void* NULLABLE(HashMap_tryGetPtr)(HashMap_* ptr, str key);
|
void* NULLABLE(HashMap_tryGetPtr)(HashMap_* ptr, str key);
|
||||||
bool HashMap_tryPush(HashMap_* ptr, str key, void* value_ptr);
|
bool HashMap_tryPush(HashMap_* ptr, str key, void* value_ptr);
|
||||||
|
|||||||
@ -13,10 +13,11 @@ static const Array(u32) __HashMap_heights = ARRAY(u32, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
void HashMap_create_size(HashMap_* ptr, u32 value_t_size, FreeFunction NULLABLE(value_destructor)){
|
void HashMap_construct_size(HashMap_* ptr, u32 value_t_size, FreeFunction NULLABLE(value_destructor)){
|
||||||
ptr->value_t_size = value_t_size;
|
ptr->value_t_size = value_t_size;
|
||||||
ptr->value_destructor = value_destructor;
|
ptr->value_destructor = value_destructor;
|
||||||
ptr->height_n = 0;
|
ptr->height_n = 0;
|
||||||
|
//TODO: make first height == 0 and call malloc later
|
||||||
ptr->height = ((u32*)__HashMap_heights.data)[0];
|
ptr->height = ((u32*)__HashMap_heights.data)[0];
|
||||||
u32 alloc_size = ptr->height * sizeof(HashMapBucket);
|
u32 alloc_size = ptr->height * sizeof(HashMapBucket);
|
||||||
ptr->table = (HashMapBucket*)malloc(alloc_size);
|
ptr->table = (HashMapBucket*)malloc(alloc_size);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user