Magic number in boost::hash_combine
-
07-11-2019 - |
문제
The boost::hash_combine
template function takes a reference to a hash (called seed
) and an object v
. According to the docs, it combines seed
with the hash of v
by
seed ^= hash_value(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
I can see that this is deterministic. I see why a XOR is used.
I bet the addition helps in mapping similar values widely apart so probing hash tables won't break down, but can someone explain what the magic constant is?
올바른 솔루션이 없습니다
제휴하지 않습니다 StackOverflow