X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fhash.h;h=85ee5dd74c046a4cdbc3b793cfd07d22dca2132f;hp=d696cae5b63542e65d6718f1012d0606b9f55833;hb=b116e161e377da0e4e52f07745ecb2d22f962ae9;hpb=062b200b08ec5998c4c02326e1e7b4e71fe4a5c6 diff --git a/source/core/hash.h b/source/core/hash.h index d696cae..85ee5dd 100644 --- a/source/core/hash.h +++ b/source/core/hash.h @@ -1,8 +1,8 @@ #ifndef MSP_CORE_HASH_H_ #define MSP_CORE_HASH_H_ +#include #include -#include "inttypes.h" namespace Msp { @@ -11,7 +11,7 @@ Computes a 32-bit Fowler-Noll-Vo (FNV-1a) hash. The number of bits can be limited to less than 32, in which case XOR-folding is used to reduce the hash size. */ -UInt32 hash32(const void *, unsigned, unsigned = 32); +std::uint32_t hash32(const void *, unsigned, unsigned = 32); /** Convenience function to compute a 32-bit hash of a string. @@ -23,18 +23,18 @@ inline unsigned hash32(const std::string &s, unsigned b = 32) Computes a 64-bit Fowler-Noll-Vo (FNV-1a) hash. Note that even if bits is limited to 32 or less, this does not produce the same result as hash32. */ -UInt64 hash64(const void *, unsigned, unsigned = 64); +std::uint64_t hash64(const void *, unsigned, unsigned = 64); /** Convenience function to compute a 64-bit hash of a string. */ -inline UInt64 hash64(const std::string &s, unsigned b = 64) +inline std::uint64_t hash64(const std::string &s, unsigned b = 64) { return hash64(s.data(), s.size(), b); } -inline UInt32 fold32(UInt64 hash) +inline std::uint32_t fold32(std::uint64_t hash) { return hash^(hash>>32); } -inline UInt16 fold16(UInt64 hash) +inline std::uint16_t fold16(std::uint64_t hash) { return hash^(hash>>16)^(hash>>32)^(hash>>48); } } // namespace Msp