From 8f67113e7407f9b91c11cb0b8d664207cef0f38e Mon Sep 17 00:00:00 2001 From: Radovan Kofira Date: Tue, 10 Nov 2020 19:50:23 +0100 Subject: [PATCH] nieco viac --- cv6/a_station.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cv6/a_station.c b/cv6/a_station.c index 7db3a76..afe4ffa 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -28,7 +28,13 @@ void destroy_station(struct station* station){ int select_track(struct station* station, const char* target){ unsigned long hash=0; - int i,len; + + for(int i=0;target[i]!='\0';i++){ + hash= target[i] + (hash << 6) + (hash <<16)-hash; + } + hash = hash%station->track_count; + return hash; + /* int i,len; for(hash = i = 0; i <'\0' ; ++i) { hash += target[i]; @@ -38,7 +44,7 @@ for(hash = i = 0; i <'\0' ; ++i) hash += (hash << 3); hash ^= (hash >> 11); hash += (hash << 15); - return hash; + return hash;*/ } void add_target_capacity(struct station* station,const char* target, int capacity){