about hash

Hi
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???

  return h;
  }

Have a nice day!
Ciao
Cloud

Hi,

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.

Cheers,
Christian.