
Hi, Does the hash function uses a seed? If a call: boost::hashstd::string string_hash; std::size_t h = string_hash("Hash me"); and then after a year I call again: string_hash("Hash me"); Does it return the same value? Thanks a lot, Ray

Rares Vernica wrote:
Hi,
Does the hash function uses a seed?
If a call: boost::hashstd::string string_hash; std::size_t h = string_hash("Hash me");
and then after a year I call again: string_hash("Hash me");
Does it return the same value?
Yes; a hash is a (pure, deterministic) function of its input value, i.e., a function in the mathematical sense as well as the C++ sense. Any hash must satisfy that property or algorithms using it will behave in rather strange/unpredictable ways. -- James

OK. Thank you very much, Ray James Dennett wrote:
Rares Vernica wrote:
Hi,
Does the hash function uses a seed?
If a call: boost::hashstd::string string_hash; std::size_t h = string_hash("Hash me");
and then after a year I call again: string_hash("Hash me");
Does it return the same value?
Yes; a hash is a (pure, deterministic) function of its input value, i.e., a function in the mathematical sense as well as the C++ sense. Any hash must satisfy that property or algorithms using it will behave in rather strange/unpredictable ways.
-- James
participants (2)
-
James Dennett
-
Rares Vernica