mirror of
https://github.com/greg7mdp/parallel-hashmap.git
synced 2026-08-30 00:50:38 +08:00
add couple examples
This commit is contained in:
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
#ifndef phmap_example_hash_std_
|
||||
#define phmap_example_hash_std_
|
||||
|
||||
#include <parallel_hashmap/phmap_utils.h>
|
||||
|
||||
using std::string;
|
||||
|
||||
struct Person
|
||||
{
|
||||
bool operator==(const Person &o) const
|
||||
{
|
||||
return _first == o._first && _last == o._last;
|
||||
}
|
||||
|
||||
string _first;
|
||||
string _last;
|
||||
};
|
||||
|
||||
namespace std
|
||||
{
|
||||
// inject specialization of std::hash for Person into namespace std
|
||||
// ----------------------------------------------------------------
|
||||
template<>
|
||||
struct hash<Person>
|
||||
{
|
||||
std::size_t operator()(Person const &p) const
|
||||
{
|
||||
std::size_t seed = 0;
|
||||
phmap::hash_combine(seed, p._first);
|
||||
phmap::hash_combine(seed, p._last);
|
||||
return seed;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // phmap_example_hash_std_
|
||||
Reference in New Issue
Block a user