Fixing adding problem and collisions
This commit is contained in:
parent
f82ebaf248
commit
fbe11df4a8
@ -18,7 +18,7 @@ void destroy_station(struct station* station){
|
|||||||
int select_track(struct station* station, const char* target){
|
int select_track(struct station* station, const char* target){
|
||||||
int hash = 0;
|
int hash = 0;
|
||||||
for (int i = 0; i < strlen(target); i++)
|
for (int i = 0; i < strlen(target); i++)
|
||||||
{ hash += target[i];
|
{ hash += target[i] + (hash<<6) + (hash<<16) - hash;
|
||||||
|
|
||||||
}
|
}
|
||||||
hash = hash %station->track_count;
|
hash = hash %station->track_count;
|
||||||
@ -35,7 +35,7 @@ void add_target_capacity(struct station* station,const char* target, int capacit
|
|||||||
if(count == res){
|
if(count == res){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (strcmp(ptr->value, target) ==0){
|
else if (strcmp(ptr->value, target) ==0 ){
|
||||||
ptr->capacity += capacity;
|
ptr->capacity += capacity;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user