latest non functioning hasmap
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
CC := "cc"
|
CC := "zig cc"
|
||||||
CFLAGS := "-pedantic -Wall -Wextra -Wno-override-init -O0 -g -fno-omit-frame-pointer -fno-inline"
|
CFLAGS := "-pedantic -Wall -Wextra -Wno-override-init -O0 -g -fno-omit-frame-pointer -fno-inline"
|
||||||
LDFLAGS := if os() == "macos" {
|
LDFLAGS := if os() == "macos" {
|
||||||
"$(pkg-config --libs --cflags criterion)"
|
"$(pkg-config --libs --cflags criterion)"
|
||||||
@@ -18,11 +18,14 @@ FOOBAR_SOURCE := FOOBAR+".c"
|
|||||||
FOOBAR_BIN := TMP/FOOBAR
|
FOOBAR_BIN := TMP/FOOBAR
|
||||||
FOOBAR_EXPANDED := TMP/FOOBAR+"-expanded.c"
|
FOOBAR_EXPANDED := TMP/FOOBAR+"-expanded.c"
|
||||||
|
|
||||||
|
build_foobar2:
|
||||||
|
{{CC}} {{FOOBAR_SOURCE}} {{CFLAGS}} -o foobar2
|
||||||
|
|
||||||
run_foobar: build_foobar
|
run_foobar: build_foobar
|
||||||
./{{FOOBAR_BIN}}
|
{{FOOBAR_BIN}}
|
||||||
|
|
||||||
build_foobar: foobar_expanded
|
build_foobar: foobar_expanded
|
||||||
{{CC}} {{FOOBAR_EXPANDED}} -o {{FOOBAR_BIN}} {{CFLAGS}}
|
{{CC}} {{FOOBAR_EXPANDED}} {{CFLAGS}} -o {{FOOBAR_BIN}}
|
||||||
echo "{{FOOBAR_BIN}}"
|
echo "{{FOOBAR_BIN}}"
|
||||||
|
|
||||||
foobar_expanded:
|
foobar_expanded:
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ index_pair_t map_pair_hash(void *this, void *pair) {
|
|||||||
mapping_index = (mapping_index + 1) % header->mapping_capacity;
|
mapping_index = (mapping_index + 1) % header->mapping_capacity;
|
||||||
existing_value_index = header->mapping_arr[mapping_index];
|
existing_value_index = header->mapping_arr[mapping_index];
|
||||||
}
|
}
|
||||||
|
// TODO FUCKING IDIOT! has_old_index is set to true for NO REASON. Why???
|
||||||
|
|
||||||
// Whatever is at index is either free, or the key is already in the map.
|
// Whatever is at index is either free, or the key is already in the map.
|
||||||
//
|
//
|
||||||
@@ -234,7 +235,7 @@ void map_assure_growable_by_1(void **this, const char *file, int line) {
|
|||||||
// The reason for re-hashing is that all hashes are moduloed by the
|
// The reason for re-hashing is that all hashes are moduloed by the
|
||||||
// size of the mapping array, so the resulting hash will likely change.
|
// size of the mapping array, so the resulting hash will likely change.
|
||||||
for ( unsigned int i = 0; i < header->n_items; i++ ) {
|
for ( unsigned int i = 0; i < header->n_items; i++ ) {
|
||||||
void *pair = &((uint8_t *)(*this))[i*header->item_size];
|
void *pair = &(((uint8_t *)(*this))[i*header->item_size]);
|
||||||
// This is okay, because we absolutely know that the keys don't already
|
// This is okay, because we absolutely know that the keys don't already
|
||||||
// exist. (assuming all the other code for map is doing it's job)
|
// exist. (assuming all the other code for map is doing it's job)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user