some slight progress
map/set still buggy
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
#define CIG_IMPL
|
#define CIG_IMPL
|
||||||
#include "cig.h"
|
#include "cig.h"
|
||||||
|
|
||||||
int main() {
|
int main(void) {
|
||||||
with_borrow(allocator) {
|
with_borrow(allocator) {
|
||||||
int *ints;
|
int *ints;
|
||||||
set_init(&ints, allocator, .initial_capacity=20);
|
set_init(&ints, allocator, .initial_capacity=20);
|
||||||
map_print_mapping_state(ints, stdout);
|
map_print_mapping_state(ints, stdout);
|
||||||
for ( int i = 0; i < 1000; i++ ) {
|
for ( int i = 0; i < 20; i++ ) {
|
||||||
set_add(&ints, i);
|
set_add(&ints, i);
|
||||||
map_print_mapping_state(ints, stdout);
|
map_print_mapping_state(ints, stdout);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ static int internal_map_mod(int a, int b) {
|
|||||||
|
|
||||||
void map_print_mapping_state(void *this, FILE *file) {
|
void map_print_mapping_state(void *this, FILE *file) {
|
||||||
map_header_t *header = PTR_FROM_FIELD_PTR(map_header_t, bytes, this);
|
map_header_t *header = PTR_FROM_FIELD_PTR(map_header_t, bytes, this);
|
||||||
for ( int i = 0; i < header->mapping_capacity; i++ ) {
|
for ( unsigned int i = 0; i < header->mapping_capacity; i++ ) {
|
||||||
int mapping = header->mapping_arr[i];
|
int mapping = header->mapping_arr[i];
|
||||||
|
|
||||||
if (mapping == FLAG_TOMBSTONE) {
|
if (mapping == FLAG_TOMBSTONE) {
|
||||||
@@ -131,6 +131,7 @@ unsigned int map_place(void *this, index_pair_t idx_pair) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
header->mapping_arr[idx_pair.new_index] = header->n_items;
|
header->mapping_arr[idx_pair.new_index] = header->n_items;
|
||||||
|
header->n_items++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return header->mapping_arr[idx_pair.new_index];
|
return header->mapping_arr[idx_pair.new_index];
|
||||||
|
|||||||
Reference in New Issue
Block a user