From 55b04a94e77ab7a751d0a2e369ff09cd747570cb Mon Sep 17 00:00:00 2001 From: Radovan Kofira Date: Tue, 10 Nov 2020 20:11:19 +0100 Subject: [PATCH] nieco viac --- cv6/a_station.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/cv6/a_station.c b/cv6/a_station.c index 4223919..5f7e03d 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -27,29 +27,13 @@ void destroy_station(struct station* station){ } int select_track(struct station* station, const char* target){ - unsigned long - hash(unsigned char *str) - { - unsigned long hash = 5381; - int c; - - while (c = *str++) - hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ - - return hash; + unsigned long hash=0; + for(int i=0;target[i]!='\0';i++){ + hash = ((hash << 5) + hash) + target[i]; /* hash * 33 + c */ } - /* int i,len; -for(hash = i = 0; i <'\0' ; ++i) - { - hash += target[i]; - hash += (hash << 10); - hash ^= (hash >> 6); + hash = hash%station->track_count; + return hash; } - hash += (hash << 3); - hash ^= (hash >> 11); - hash += (hash << 15); - return hash;*/ -} void add_target_capacity(struct station* station,const char* target, int capacity){ }