Turi Create
4.0
city_hasher.hh
1
#ifndef _CITY_HASHER_HH
2
#define _CITY_HASHER_HH
3
4
#include <city.h>
5
#include <string>
6
7
/** \ingroup util
8
* \addtogroup Hashing
9
* CityHasher is a std::hash-style wrapper around CityHash. We
10
* encourage using CityHasher instead of the default std::hash if
11
* possible. */
12
template
<
class
Key>
13
class
CityHasher {
14
public
:
15
size_t
operator()(
const
Key& k)
const
{
16
return
CityHash64((
const
char
*) &k,
sizeof
(k));
17
}
18
};
19
20
/** \ingroup util
21
* \addtogroup Hashing
22
* This is a template specialization of CityHasher for
23
* std::string. */
24
template
<>
25
class
CityHasher<
std
::string> {
26
public
:
27
size_t
operator()(
const
std::string& k)
const
{
28
return
CityHash64(k.c_str(), k.size());
29
}
30
};
31
32
#endif // _CITY_HASHER_HH
std
STL namespace.
core
util
city_hasher.hh
Generated by
1.8.13