blob: 3fd246fa170a375b02f3b678a228074e5706d446 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#pragma once
#include <cybozu/inttype.hpp>
namespace cybozu {
template<class Iter>
uint32_t hash32(Iter begin, Iter end, uint32_t v = 0)
{
if (v == 0) v = 2166136261U;
while (begin != end) {
v ^= *begin++;
v *= 16777619;
}
return v;
}
template<class Iter>
uint64_t hash64(Iter begin, Iter end, uint64_t v = 0)
{
if (v == 0) v = 14695981039346656037ULL;
while (begin != end) {
v ^= *begin++;
v *= 1099511628211ULL;
}
v ^= v >> 32;
return v;
}
template<class T>
uint32_t hash32(const T *x, size_t n, uint32_t v = 0)
{
return hash32(x, x + n, v);
}
template<class T>
uint64_t hash64(const T *x, size_t n, uint64_t v = 0)
{
return hash64(x, x + n, v);
}
} // cybozu
namespace boost {
template<class T>
struct hash;
} // boost
#if CYBOZU_CPP_VERSION >= CYBOZU_CPP_VERSION_CPP11
#include <functional>
#else
namespace std { CYBOZU_NAMESPACE_TR1_BEGIN
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4099) // missmatch class and struct
#endif
#ifndef __APPLE__
template<class T>
struct hash;
#endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif
CYBOZU_NAMESPACE_TR1_END } // std
#endif
|