X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;ds=inline;f=selector.cc;h=e9b4f648c4804b1577a7b781f51c37821291f890;hb=919a7e0c12d771d722d87cbc00d991e406f30a30;hp=c6cf64cb9574cb9334c8d4ae961955bba1804475;hpb=8b0d331c335d51f61c1a56b98e05f91bd53a1441;p=selector.git diff --git a/selector.cc b/selector.cc index c6cf64c..e9b4f64 100644 --- a/selector.cc +++ b/selector.cc @@ -104,8 +104,11 @@ int test_and_add(char *new_string, int new_index, char **strings, int *hash_table, int hash_table_size) { unsigned int code = 0; + // This is my recipe. I checked, it seems to work (as long as + // hash_table_size is not a multiple of 387433 that should be okay) + for(int k = 0; new_string[k]; k++) { - code += int(new_string[k]) << (8 * k%4); + code = code * 387433 + (unsigned int) (new_string[k]); } code = code % hash_table_size; @@ -469,7 +472,7 @@ int main(int argc, char **argv) { } else { - cerr << "Selector version " << VERSION + cerr << "Selector version " << VERSION << "-R" << REVISION_NUMBER << endl << "Written by Francois Fleuret " << endl