This commit is contained in:
eason 2023-12-21 10:41:27 +08:00
parent 02e0d1d86f
commit a967a59145
5 changed files with 90831 additions and 28 deletions

89421
a.txt Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -91,17 +91,18 @@ void debug_head(struct Node* head){
struct Node* previous=NULL; struct Node* previous=NULL;
struct Node* current=head; struct Node* current=head;
printf("start of address:"); // printf("start of address:");
while(current!=NULL){ while(current!=NULL){
struct Node* next=xor_next(previous,current); struct Node* next=xor_next(previous,current);
struct SizedSubmask* mask=current->val; struct SizedSubmask* mask=current->val;
printf("%zu ,",current); // printf("%zu ,",current);
// fflush(stdout);
previous=current; previous=current;
current=next; current=next;
} }
printf("\n"); // printf("\n");
} }
// int test() // int test()
// { // {

View File

@ -33,17 +33,11 @@ struct Node* xor_remove_match(struct Node* head,void* target,bool (*eq)(void *,v
else return head; else return head;
} }
bool xor_contain(struct Node* head,void* target,bool (*eq)(void *,void *)){ bool xor_contain(struct Node* current,void* target,bool (*eq)(void *,void *)){
struct Node* previous=NULL; struct Node* previous=NULL;
struct Node* current=head;
usize round=0;
while(current!=NULL){ while(current!=NULL){
// if(current<((usize)100000)) break;
// printf("current: %zu, previous: %zu, round: %zu\n",current,previous, ++round);
struct Node* next=xor_next(previous,current); struct Node* next=xor_next(previous,current);
if(eq(current->val,target)){ if(eq(current->val,target))return true;
return true;
}
previous=current; previous=current;
current=next; current=next;
} }
@ -64,15 +58,16 @@ void prefix_insert(struct State* state){
parse_submask(buffer,mask); parse_submask(buffer,mask);
struct SizedSubmask* ip=clone_submask(mask); struct SizedSubmask* ip=clone_submask(mask);
record_start // record_start
if(reduce_submask(mask)){ if(reduce_submask(mask)){
struct Node* ll=hash_pop(state->hashmap,mask); struct Node* ll=hash_pop(state->hashmap,mask);
struct Node* new=xor_insert_mid(NULL,ll,ip); struct Node* new=xor_insert_mid(NULL,ll,ip);
hash_insert(state->hashmap,mask,new); hash_insert(state->hashmap,mask,new);
}else state->head=xor_insert_mid(NULL,state->head,ip); }else state->head=xor_insert_mid(NULL,state->head,ip);
record_end("prefix_insert.csv") // record_end("prefix_insert.csv")
freq++; freq++;
} }
@ -99,7 +94,8 @@ void prefix_delete(struct State* state){
if(reduce_submask(mask)){ if(reduce_submask(mask)){
struct Node* ll=hash_pop(state->hashmap,mask); struct Node* ll=hash_pop(state->hashmap,mask);
struct Node* new_head=xor_remove_match(ll,ip,eq_v3); struct Node* new_head=xor_remove_match(ll,ip,eq_v3);
if(new_head!=NULL) hash_insert(state->hashmap,mask,new_head);
if(new_head!=NULL)hash_insert(state->hashmap,mask,new_head);
}else{ }else{
struct Node* ll=state->head; struct Node* ll=state->head;
struct Node* new_head=xor_remove_match(ll,ip,eq_v3); struct Node* new_head=xor_remove_match(ll,ip,eq_v3);
@ -109,6 +105,7 @@ void prefix_delete(struct State* state){
record_end("prefix_delete.csv") record_end("prefix_delete.csv")
free(ip); free(ip);
} }
@ -131,21 +128,48 @@ void search(struct State* state){
record_start record_start
struct Node* ll; if(reduce_submask(mask)){
if(reduce_submask(mask))ll=hash_get(state->hashmap,mask); struct Node* ll=hash_pop(state->hashmap,mask);
else ll=state->head; freq++;
freq++;
record_end("search.csv") record_end("search.csv")
debug_head(ll); fflush(stdout);
if (xor_contain(ll,ip,eq_v3)) printf("successful\n"); if (xor_contain(ll,ip,eq_v3)) printf("successful\n");
else printf("failed\n"); else printf("failed\n");
hash_insert(state->hashmap,mask,ll);
}else{
struct Node* ll=state->head;
freq++;
fflush(stdout);
if (xor_contain(ll,ip,eq_v3)) printf("successful\n");
else printf("failed\n");
free(mask);
}
record_end("search.csv")
free(ip); free(ip);
free(mask);
// if(reduce_submask(mask))ll=hash_get(state->hashmap,mask);
// else ll=state->head;
// freq++;
// record_end("search.csv")
// printf("head: %zu\n",ll);
// fflush(stdout);
// if (xor_contain(ll,ip,eq_v3)) printf("successful\n");
// else printf("failed\n");
// free(ip);
// free(mask);
} }
clock_end clock_end

File diff suppressed because it is too large Load Diff