christian at whoop.org
Tue Dec 31 08:08:01 PST 2002
On Tue, 2002-12-31 at 06:14, Wang Shaofu wrote:
> Looking for help!
> hash_t HashKey::HashBytes(const void* bytes, int size) const
> const unsigned char* cp = (const unsigned char*) bytes;
> hash_t h = 0;//unsigned int
> for ( int i = 0; i < size; ++i )
> // Overflow is okay here.
> h = (h >> 31) + (h << 1) + cp[i];
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~This arithmetic make
> sure there is no collision????
I'm not familiar with the rest of the HashKey class, but calculation of
a hash key as in this case doesn't take care of collisions -- they're
resolved later, when looking up an item in a hash table.
More information about the Bro