Change how demand categories linked-list is constructed (appending instead of prepending)

Fix #150
This wasn't changed but one should note that the default pattern is used and saved if none assigned to a demand
This commit is contained in:
Elad Salomons
2018-04-09 15:01:27 +03:00
parent 780698ccf9
commit b85aff9fc9

View File

@@ -112,7 +112,7 @@ int juncdata(EN_Project *pr)
} }
demand->Base = y; demand->Base = y;
demand->Pat = p; demand->Pat = p;
demand->next = node->D; demand->next = NULL;
node->D = demand; node->D = demand;
hyd->NodeDemand[Njuncs] = y; hyd->NodeDemand[Njuncs] = y;
@@ -737,6 +737,7 @@ int demanddata(EN_Project *pr)
int j, n, p = 0; int j, n, p = 0;
double y; double y;
Pdemand demand; Pdemand demand;
Pdemand cur_demand;
STmplist *pat; STmplist *pat;
/* Extract data from tokens */ /* Extract data from tokens */
@@ -778,13 +779,17 @@ int demanddata(EN_Project *pr)
hyd->NodeDemand[j] = MISSING; // marker - next iteration will append a new category. hyd->NodeDemand[j] = MISSING; // marker - next iteration will append a new category.
} }
else { // add new demand to junction else { // add new demand to junction
cur_demand = net->Node[j].D;
while (cur_demand->next != NULL) {
cur_demand = cur_demand->next;
}
demand = (struct Sdemand *)malloc(sizeof(struct Sdemand)); demand = (struct Sdemand *)malloc(sizeof(struct Sdemand));
if (demand == NULL) if (demand == NULL)
return (101); return (101);
demand->Base = y; demand->Base = y;
demand->Pat = p; demand->Pat = p;
demand->next = net->Node[j].D; demand->next = NULL;
net->Node[j].D = demand; cur_demand->next = demand;
} }
return (0); return (0);
} /* end of demanddata */ } /* end of demanddata */