Aktualizovat du6/a_station.c
This commit is contained in:
parent
b33e3c9c79
commit
ca67fe9fd4
@ -17,7 +17,7 @@ void destroy_station(struct station* station)
|
||||
}
|
||||
|
||||
//preiteruje cez kazdy jeden 'track/carar' v poli 'tracks' a
|
||||
for (int i = 0; i < station->track_count, i++)
|
||||
for (int i = 0; i < station->track_count; i++)
|
||||
{
|
||||
struct car* currentTracks = station->tracks;
|
||||
while (currentTracks->next != NULL)
|
||||
@ -37,6 +37,17 @@ int select_track(struct station* station, const char* target)
|
||||
{
|
||||
station = (struct station*)calloc(1, sizeof(station));
|
||||
}
|
||||
|
||||
// vyuzitie 'djb2' hashovacieho algorithmu..
|
||||
unsigned long hash_value = 5381;
|
||||
int i = 0;
|
||||
|
||||
while (target[i] != '\0') {
|
||||
// viacej 'human readable' verzia algorithmu.
|
||||
//Pri hashovacich funkciach je zvykom pouzivat bitwise operator ('>>') na docielenie rovnakeho vysledku
|
||||
hash_value = (hash_value * 33) + target[i];
|
||||
i++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user