mirror of
https://github.com/ETLCPP/etl.git
synced 2026-11-09 14:49:53 +08:00
Added 16 bit generic_hash for systems where size_t is 16 bit.
This commit is contained in:
parent
eea2af244b
commit
cb9f619107
15
src/hash.h
15
src/hash.h
@ -45,8 +45,22 @@ namespace etl
|
||||
{
|
||||
namespace __private_hash__
|
||||
{
|
||||
//*************************************************************************
|
||||
/// Hash to use when size_t is 16 bits.
|
||||
/// T is always expected to be size_t.
|
||||
//*************************************************************************
|
||||
template <typename T>
|
||||
typename enable_if<sizeof(T) == sizeof(uint16_t), size_t>::type
|
||||
generic_hash(uint8_t* begin, uint8_t* end)
|
||||
{
|
||||
uint32_t h = fnv_1a_32(begin, end);
|
||||
|
||||
return static_cast<size_t>(h ^ (h >> 16));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Hash to use when size_t is 32 bits.
|
||||
/// T is always expected to be size_t.
|
||||
//*************************************************************************
|
||||
template <typename T>
|
||||
typename enable_if<sizeof(T) == sizeof(uint32_t), size_t>::type
|
||||
@ -57,6 +71,7 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Hash to use when size_t is 64 bits.
|
||||
/// T is always expected to be size_t.
|
||||
//*************************************************************************
|
||||
template <typename T>
|
||||
typename enable_if<sizeof(T) == sizeof(uint64_t), size_t>::type
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user