hashmap init seems to be done
missing any testing though
This commit is contained in:
@@ -238,26 +238,16 @@ void arr_qsort(void *this, dyn_array_cmp_fn cmp_fn);
|
||||
typedef int (*hash_func_t)(void *key);
|
||||
typedef int (*equals_func_t)(void *key1, void *key2);
|
||||
|
||||
// TODO: after this comes the actual hash map. it maps keys to indexes into the
|
||||
// key-value pair array. (which does not actually need values, only a key
|
||||
// field.)
|
||||
// TODO: This means that when allocating memory for the array of key-value
|
||||
// pairs, we actually need to allocate it in terms of the max_align type, and
|
||||
// increase in size by using that size as the smallest increment. Which will
|
||||
// keep the hash array aligned properly in memory.
|
||||
|
||||
typedef struct hashmap_header {
|
||||
int n_items, capacity, itemsize, keysize;
|
||||
int n_items, capacity, itemsize, keysize, mapping_capacity;
|
||||
allocator_t allocator;
|
||||
hash_func_t hash;
|
||||
equals_func_t equals;
|
||||
int *mapping_arr;
|
||||
union {
|
||||
uint8_t bytes[1];
|
||||
any_align_t _[1];
|
||||
};
|
||||
// The above union is actually a different size. Then comes an array of
|
||||
// integers which is double the size of n_items * sizeof(int). int
|
||||
// indexes[...];
|
||||
} hashmap_header_t;
|
||||
|
||||
typedef struct hashmap_create_func_args {
|
||||
@@ -283,8 +273,6 @@ void *hashmap_create_func(hashmap_create_func_args_t args);
|
||||
}); \
|
||||
} while(0);
|
||||
|
||||
// TODO this shite
|
||||
|
||||
// CLI /////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define CLI_UNIQUE1 __macro_internal_34bba35b8b9b20a75f9881e3795630e25d36e620d9c9741e2e9141ba82ec6ef7__
|
||||
|
||||
Reference in New Issue
Block a user