forked from rmbianchi/concurrent_framework
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ConcurrentTypes.h
37 lines (31 loc) · 1019 Bytes
/
ConcurrentTypes.h
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
/**
* ConcurrentTypes.h
*
* Created on: Feb 12, 2012
* Author: [email protected] (Benedikt HEGNER)
*/
#ifndef CONCURRENTTYPES_H_
#define CONCURRENTTYPES_H_
// include c++
#include <string>
// TBB headers
#include "tbb/concurrent_hash_map.h"
// use unsigned int as DataItem
typedef unsigned int DataItem;
// Hash&Compare functions for various types used
// TODO: replace the string hash by a better implementation, murmur etc.
struct StringHashCompare {
static size_t hash( const std::string& x ) {
size_t h = 0;
for( const char* s = x.c_str(); *s; ++s )
h = (h*17)^*s;
return h;
}
static bool equal( const std::string& x, const std::string& y ) {
return x==y;
}
};
typedef tbb::concurrent_hash_map<std::string, unsigned int, StringHashCompare> StringUIntMap;
typedef tbb::concurrent_hash_map<std::string, int, StringHashCompare> StringIntMap;
typedef tbb::concurrent_hash_map<std::string, DataItem, StringHashCompare> StringDataMap;
#endif /* CONCURRENTTYPES_H_ */