Make rexy::hash work on c++ standard containers
This commit is contained in:
parent
11ea9db137
commit
7f9a1195fa
@ -26,7 +26,7 @@ namespace rexy{
|
|||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
struct hash{
|
struct hash{
|
||||||
constexpr size_t operator()(const T& t, size_t salt)const noexcept{
|
constexpr size_t operator()(const T& t, size_t salt = 0)const noexcept{
|
||||||
constexpr size_t bytes = sizeof(size_t);
|
constexpr size_t bytes = sizeof(size_t);
|
||||||
size_t val = static_cast<size_t>(t);
|
size_t val = static_cast<size_t>(t);
|
||||||
size_t hash = 5381 + salt; //magic hash number
|
size_t hash = 5381 + salt; //magic hash number
|
||||||
|
|||||||
@ -27,7 +27,7 @@ namespace rexy{
|
|||||||
//jenkns one at a time hash
|
//jenkns one at a time hash
|
||||||
template<class Str>
|
template<class Str>
|
||||||
struct string_hash{
|
struct string_hash{
|
||||||
constexpr size_t operator()(const Str& s, size_t salt)const noexcept{
|
constexpr size_t operator()(const Str& s, size_t salt = 0)const noexcept{
|
||||||
size_t hash = salt;
|
size_t hash = salt;
|
||||||
for(size_t i = 0;i < s.length();++i){
|
for(size_t i = 0;i < s.length();++i){
|
||||||
hash += s[i];
|
hash += s[i];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user