2 hash.cc -- implement various functions for hash tables.
4 source file of the Flower Library
6 (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "dictionary.hh"
14 // Note: assumes long is at least 32 bits.
15 const unsigned long my_prime_list
[] =
17 5, 11, 23, // be a bit careful for short lists: we want reasonable mem usage.
18 53, 97, 193, 389, 769,
19 1543, 3079, 6151, 12289, 24593,
20 49157, 98317, 196613, 393241, 786433,
21 1572869, 3145739, 6291469, 12582917, 25165843,
22 50331653, 100663319, 201326611, 402653189u, 805306457u,
23 1610612741u, 3221225473u, 4294967291u
29 return my_prime_list
[idx
];
33 string_hash (String s
)
35 const char* str
= s
.to_str0 ();
36 unsigned int result
= 0;
40 result
+= (result
<<3) + c
;