main page
namespaces
classes
files
GGL home
Generated on Wed Apr 29 2015 11:51:40 for GGL-4.1.2 by
doxygen
1.8.3.1
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
src
sgm
HashMap.hh
Go to the documentation of this file.
1
#ifndef SGM_HASHMAP_HH_
2
#define SGM_HASHMAP_HH_
3
4
////////////////////////////////////////////////////////////////////////////////
5
// STANDARD UNORDERED MAP FLAG
6
// 1 - if the header <unordered_map> is available
7
// (e.g. for using std::unordered_map<int,int>)
8
// 0 - otherwise
9
////////////////////////////////////////////////////////////////////////////////
10
11
#define HAVE_UNORDERED_MAP 0
12
13
14
15
////////////////////////////////////////////////////////////////////////////////
16
// STANDARD TEST RELEASE 1 UNORDERED MAP FLAG
17
// 1 - if the header <tr1/unordered_map> is available
18
// (e.g. for using std::tr1::unordered_map<int,int>)
19
// 0 - otherwise
20
////////////////////////////////////////////////////////////////////////////////
21
22
#define HAVE_TR1_UNORDERED_MAP 1
23
24
25
26
////////////////////////////////////////////////////////////////////////////////
27
// GNU HASH MAP FLAG
28
// 1 - if the header <ext/hash_map> is available
29
// (e.g. for using __gnu_cxx::hash_map<int,int>)
30
// 0 - otherwise
31
////////////////////////////////////////////////////////////////////////////////
32
33
#define HAVE_GNU_HASH_MAP 1
34
35
36
37
#if HAVE_GNU_HASH_MAP > 0
38
39
#include <string>
40
namespace
sgm {
41
42
/*! Daniel J. Bernstein's string hash function
43
* taken from http://www.cs.yorku.ca/~oz/hash.html.
44
*/
45
class
hash_string
{
46
public
:
47
48
size_t
operator()
(
const
std::string& str)
const
49
{
50
size_t
hash = 5381;
51
52
for
(
size_t
i = 0; i < str.size(); i++) {
53
// hash * 33 + str[i]
54
hash = ((hash << 5) + hash) + (size_t)str[i];
55
}
56
57
return
hash;
58
}
59
60
};
61
62
}
// namespace sgm
63
64
#endif
65
66
////////////////////////////////////////////////////////////////////////////////
67
68
69
70
71
#endif
/*SGM_HASHMAP_HH_*/