Я работаю с таблицами хэша, и я наткнулся на эту функцию. Но что означает hash/sizeof (void *)? и комментарий после него - избавиться от известных-0 бит?Что означает разделение на sizeof (void *)?
// This matches when the hashtable key is a pointer.
template<class HashKey> class hash_munger<HashKey*> {
public:
static size_t MungedHash(size_t hash) {
// TODO(csilvers): consider rotating instead:
// static const int shift = (sizeof(void *) == 4) ? 2 : 3;
// return (hash << (sizeof(hash) * 8) - shift)) | (hash >> shift);
// This matters if we ever change sparse/dense_hash_* to compare
// hashes before comparing actual values. It's speedy on x86.
return hash/sizeof(void*); // get rid of known-0 bits
}
};
Похоже на [вы не должны это понимать] (http://cm.bell-labs.com/cm/cs/who/dmr/odd.html) комментарий. –