Update CP
This commit is contained in:
@@ -2,46 +2,50 @@
|
||||
#ifndef __FILE_Detail_CP_CHash_Hpp
|
||||
#define __FILE_Detail_CP_CHash_Hpp
|
||||
|
||||
#ifndef FORCEINLINE
|
||||
#define FORCEINLINE __forceinline
|
||||
#endif // !FORCEINLINE
|
||||
|
||||
//
|
||||
// Hash functions for common types.
|
||||
//
|
||||
|
||||
inline uint32_t Hash(const uint8_t A)
|
||||
FORCEINLINE uint32_t Hash(const uint8_t A)
|
||||
{
|
||||
return A;
|
||||
}
|
||||
|
||||
inline uint32_t Hash(const int8_t A)
|
||||
FORCEINLINE uint32_t Hash(const int8_t A)
|
||||
{
|
||||
return A;
|
||||
}
|
||||
|
||||
inline uint32_t Hash(const uint16_t A)
|
||||
FORCEINLINE uint32_t Hash(const uint16_t A)
|
||||
{
|
||||
return A;
|
||||
}
|
||||
|
||||
inline uint32_t Hash(const int16_t A)
|
||||
FORCEINLINE uint32_t Hash(const int16_t A)
|
||||
{
|
||||
return A;
|
||||
}
|
||||
|
||||
inline uint32_t Hash(const int32_t A)
|
||||
FORCEINLINE uint32_t Hash(const int32_t A)
|
||||
{
|
||||
return A;
|
||||
}
|
||||
|
||||
inline uint32_t Hash(const uint32_t A)
|
||||
FORCEINLINE uint32_t Hash(const uint32_t A)
|
||||
{
|
||||
return A;
|
||||
}
|
||||
|
||||
inline uint32_t Hash(const uint64_t A)
|
||||
FORCEINLINE uint32_t Hash(const uint64_t A)
|
||||
{
|
||||
return (uint32_t)A + ((uint32_t)(A >> 32) * 23);
|
||||
}
|
||||
|
||||
inline uint32_t Hash(const int64_t A)
|
||||
FORCEINLINE uint32_t Hash(const int64_t A)
|
||||
{
|
||||
return (uint32_t)A + ((uint32_t)(A >> 32) * 23);
|
||||
}
|
||||
@@ -51,7 +55,8 @@ uint32_t Hash(const char* str, uint32_t hash = 5381)
|
||||
return *str == '\0' ? hash : Hash(str + 1, ((hash << 5) + hash) + *str);
|
||||
}
|
||||
|
||||
uint32_t Hash(std::string_view str, uint32_t hash = 5381)
|
||||
template<typename StringView>
|
||||
uint32_t Hash(StringView str, uint32_t hash = 5381)
|
||||
{
|
||||
for (size_t i = 0; i < str.length(); ++i)
|
||||
{
|
||||
@@ -60,42 +65,53 @@ uint32_t Hash(std::string_view str, uint32_t hash = 5381)
|
||||
return hash;
|
||||
}
|
||||
|
||||
constexpr uint32_t CHash(const uint8_t A)
|
||||
uint32_t THash(const char* const object, unsigned int length, uint32_t hash = 5381)
|
||||
{
|
||||
return (length == 0) ? hash : THash(object + 1, length - 1, ((hash << 5) + hash) + *object);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
uint32_t THash(T* object, uint32_t hash = 5381)
|
||||
{
|
||||
return THash((char*)object, sizeof(T), hash);
|
||||
}
|
||||
|
||||
FORCEINLINE constexpr uint32_t CHash(const uint8_t A)
|
||||
{
|
||||
return A;
|
||||
}
|
||||
|
||||
constexpr uint32_t CHash(const int8_t A)
|
||||
FORCEINLINE constexpr uint32_t CHash(const int8_t A)
|
||||
{
|
||||
return A;
|
||||
}
|
||||
|
||||
constexpr uint32_t CHash(const uint16_t A)
|
||||
FORCEINLINE constexpr uint32_t CHash(const uint16_t A)
|
||||
{
|
||||
return A;
|
||||
}
|
||||
|
||||
constexpr uint32_t CHash(const int16_t A)
|
||||
FORCEINLINE constexpr uint32_t CHash(const int16_t A)
|
||||
{
|
||||
return A;
|
||||
}
|
||||
|
||||
constexpr uint32_t CHash(const int32_t A)
|
||||
FORCEINLINE constexpr uint32_t CHash(const int32_t A)
|
||||
{
|
||||
return A;
|
||||
}
|
||||
|
||||
constexpr uint32_t CHash(const uint32_t A)
|
||||
FORCEINLINE constexpr uint32_t CHash(const uint32_t A)
|
||||
{
|
||||
return A;
|
||||
}
|
||||
|
||||
constexpr uint32_t CHash(const uint64_t A)
|
||||
FORCEINLINE constexpr uint32_t CHash(const uint64_t A)
|
||||
{
|
||||
return (uint32_t)A + ((uint32_t)(A >> 32) * 23);
|
||||
}
|
||||
|
||||
constexpr uint32_t CHash(const int64_t A)
|
||||
FORCEINLINE constexpr uint32_t CHash(const int64_t A)
|
||||
{
|
||||
return (uint32_t)A + ((uint32_t)(A >> 32) * 23);
|
||||
}
|
||||
@@ -105,7 +121,8 @@ constexpr uint32_t CHash(const char* str, uint32_t hash = 5381)
|
||||
return *str == '\0' ? hash : CHash(str + 1, ((hash << 5) + hash) + *str);
|
||||
}
|
||||
|
||||
constexpr uint32_t CHash(std::string_view str, uint32_t hash = 5381)
|
||||
template<typename StringView>
|
||||
constexpr uint32_t CHash(StringView str, uint32_t hash = 5381)
|
||||
{
|
||||
for (size_t i = 0; i < str.length(); ++i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user