mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-21 14:23:03 +01:00
Cleanup.
This commit is contained in:
@@ -49,19 +49,6 @@ namespace bx
|
||||
uint32_t m_size;
|
||||
};
|
||||
|
||||
///
|
||||
uint32_t hashMurmur2A(const void* _data, uint32_t _size);
|
||||
|
||||
///
|
||||
template <typename Ty>
|
||||
uint32_t hashMurmur2A(const Ty& _data);
|
||||
|
||||
///
|
||||
uint32_t hashMurmur2A(const StringView& _data);
|
||||
|
||||
///
|
||||
uint32_t hashMurmur2A(const char* _data);
|
||||
|
||||
///
|
||||
class HashAdler32
|
||||
{
|
||||
@@ -115,6 +102,22 @@ namespace bx
|
||||
uint32_t m_hash;
|
||||
};
|
||||
|
||||
///
|
||||
template<typename HashT>
|
||||
uint32_t hash(const void* _data, uint32_t _size);
|
||||
|
||||
///
|
||||
template<typename HashT, typename Ty>
|
||||
uint32_t hash(const Ty& _data);
|
||||
|
||||
///
|
||||
template<typename HashT>
|
||||
uint32_t hash(const StringView& _data);
|
||||
|
||||
///
|
||||
template<typename HashT>
|
||||
uint32_t hash(const char* _data);
|
||||
|
||||
} // namespace bx
|
||||
|
||||
#include "inline/hash.inl"
|
||||
|
||||
@@ -136,31 +136,6 @@ namespace bx
|
||||
#undef MURMUR_R
|
||||
#undef mmix
|
||||
|
||||
inline uint32_t hashMurmur2A(const void* _data, uint32_t _size)
|
||||
{
|
||||
HashMurmur2A murmur;
|
||||
murmur.begin();
|
||||
murmur.add(_data, (int)_size);
|
||||
return murmur.end();
|
||||
}
|
||||
|
||||
template <typename Ty>
|
||||
inline uint32_t hashMurmur2A(const Ty& _data)
|
||||
{
|
||||
BX_STATIC_ASSERT(BX_TYPE_IS_POD(Ty) );
|
||||
return hashMurmur2A(&_data, sizeof(Ty) );
|
||||
}
|
||||
|
||||
inline uint32_t hashMurmur2A(const StringView& _data)
|
||||
{
|
||||
return hashMurmur2A(_data.getPtr(), _data.getLength() );
|
||||
}
|
||||
|
||||
inline uint32_t hashMurmur2A(const char* _data)
|
||||
{
|
||||
return hashMurmur2A(StringView(_data) );
|
||||
}
|
||||
|
||||
inline void HashAdler32::begin()
|
||||
{
|
||||
m_a = 1;
|
||||
@@ -201,4 +176,32 @@ namespace bx
|
||||
return m_hash;
|
||||
}
|
||||
|
||||
template<typename HashT>
|
||||
inline uint32_t hash(const void* _data, uint32_t _size)
|
||||
{
|
||||
HashT hh;
|
||||
hh.begin();
|
||||
hh.add(_data, (int)_size);
|
||||
return hh.end();
|
||||
}
|
||||
|
||||
template<typename HashT, typename Ty>
|
||||
inline uint32_t hash(const Ty& _data)
|
||||
{
|
||||
BX_STATIC_ASSERT(BX_TYPE_IS_POD(Ty) );
|
||||
return hash<HashT>(&_data, sizeof(Ty) );
|
||||
}
|
||||
|
||||
template<typename HashT>
|
||||
inline uint32_t hash(const StringView& _data)
|
||||
{
|
||||
return hash<HashT>(_data.getPtr(), _data.getLength() );
|
||||
}
|
||||
|
||||
template<typename HashT>
|
||||
inline uint32_t hash(const char* _data)
|
||||
{
|
||||
return hash<HashT>(StringView(_data) );
|
||||
}
|
||||
|
||||
} // namespace bx
|
||||
|
||||
Reference in New Issue
Block a user