From ca67fe9fd4775bb00cb928a5f63c251f60789557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Vl=C4=8Dek?= Date: Thu, 23 Apr 2026 22:20:13 +0000 Subject: [PATCH] Aktualizovat du6/a_station.c --- du6/a_station.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/du6/a_station.c b/du6/a_station.c index 581f21a..ebe7625 100644 --- a/du6/a_station.c +++ b/du6/a_station.c @@ -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; }