Files
parallel-hashmap/examples/hash_value.h
T

29 lines
852 B
C++
Raw Normal View History

2019-05-12 10:36:40 -04:00
#ifndef phmap_example_hash_value_
#define phmap_example_hash_value_
#include <parallel_hashmap/phmap_utils.h> // minimal header providing phmap::HashState()
#include <string>
using std::string;
struct Person
{
bool operator==(const Person &o) const
{
return _first == o._first && _last == o._last && _age == o._age;
}
2019-05-12 10:40:32 -04:00
// Demonstrates how to provide the hash function as a friend member function of the class
// This can be used as an alternative to providing a std::hash<Person> specialization
// --------------------------------------------------------------------------------------
2019-05-12 10:36:40 -04:00
friend size_t hash_value(const Person &p)
{
return phmap::HashState().combine(0, p._first, p._last, p._age);
}
string _first;
string _last;
int _age;
};
#endif // phmap_example_hash_value_