From: bdemsky Date: Fri, 27 Feb 2004 05:52:04 +0000 (+0000) Subject: Checking in update to hashtable code... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3211d78284a86315e994143bf725c858757563d3;p=repair.git Checking in update to hashtable code... --- diff --git a/Repair/RepairCompiler/MCC/SimpleHash.cc b/Repair/RepairCompiler/MCC/SimpleHash.cc index 0512046..ed8401d 100755 --- a/Repair/RepairCompiler/MCC/SimpleHash.cc +++ b/Repair/RepairCompiler/MCC/SimpleHash.cc @@ -185,8 +185,10 @@ int SimpleHash::remove(int key, int data) { LinkedHashNode **ptr = &bucket[hashkey]; - /* check that this key/object pair isn't already here */ - // TBD can be optimized for set v. relation */ + for (int i = 0; i < numchildren; i++) { + children[i]->remove(key, data); + } + while (*ptr) { if ((*ptr)->key == key && (*ptr)->data == data) { LinkedHashNode *toremove=*ptr; @@ -197,13 +199,11 @@ int SimpleHash::remove(int key, int data) { toremove->lnext->lprev=toremove->lprev; delete toremove; numelements--; - for (int i = 0; i < numparents; i++) { - parents[i]->add(key, data); - } return 1; } ptr = &((*ptr)->next); } + return 0; } diff --git a/Repair/RepairCompiler/MCC/ex_test.cc b/Repair/RepairCompiler/MCC/ex_test.cc index c13eae6..9b0ab1e 100755 --- a/Repair/RepairCompiler/MCC/ex_test.cc +++ b/Repair/RepairCompiler/MCC/ex_test.cc @@ -7,11 +7,16 @@ struct Node { }; int main(int argc, char **argv) { - struct Node * head =0;//(struct Node *) malloc(sizeof (struct Node)); - // head->next=0; - //head->prev=0; - -#include "ex.cc" + struct Node * head =(struct Node *) malloc(sizeof (struct Node)); + for(int i=0;i<300;i++) { + struct Node * tmp =(struct Node *) malloc(sizeof (struct Node)); + tmp->next=head; + head->prev=tmp; + head=tmp; + } + for(int j=0;j<6000;j++) { +#include "ex.cc" + } }