projects
/
selector.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Changed the hash formula. If I was not that lazy I would look at a
[selector.git]
/
selector.cc
diff --git
a/selector.cc
b/selector.cc
index
c6cf64c
..
e9b4f64
100644
(file)
--- 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;
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++) {
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;
}
code = code % hash_table_size;
@@
-469,7
+472,7
@@
int main(int argc, char **argv) {
}
else {
}
else {
- cerr << "Selector version " << VERSION
+ cerr << "Selector version " << VERSION
<< "-R" << REVISION_NUMBER
<< endl
<< "Written by Francois Fleuret <francois@fleuret.org>"
<< endl
<< endl
<< "Written by Francois Fleuret <francois@fleuret.org>"
<< endl