mirror of
https://github.com/matrix-construct/construct
synced 2024-08-23 18:14:46 +02:00
ircd::util: Add bernstein hash overloads for 16bit chars.
This commit is contained in:
parent
e3e0d81828
commit
290fa43c43
|
@ -286,6 +286,20 @@ hash(const std::string &str,
|
||||||
return i >= str.size()? 7681ULL : (hash(str, i+1) * 33ULL) ^ str.at(i);
|
return i >= str.size()? 7681ULL : (hash(str, i+1) * 33ULL) ^ str.at(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr size_t
|
||||||
|
hash(const char16_t *const &str,
|
||||||
|
const size_t i = 0)
|
||||||
|
{
|
||||||
|
return !str[i]? 7681ULL : (hash(str, i+1) * 33ULL) ^ str[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t
|
||||||
|
hash(const std::u16string &str,
|
||||||
|
const size_t i = 0)
|
||||||
|
{
|
||||||
|
return i >= str.size()? 7681ULL : (hash(str, i+1) * 33ULL) ^ str.at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* C++14 user defined literals
|
* C++14 user defined literals
|
||||||
|
|
Loading…
Reference in a new issue