27 #ifndef TBB_MAP_API_H_
28 #define TBB_MAP_API_H_
31 #include <tbb/concurrent_hash_map.h>
35 template<
class Key,
class Value>
39 static size_t hash(
const Key &k) {
41 char * temp = (
char *)(&k);
42 for (
int i = 0; i <
sizeof(Key); i++) {
49 static bool equal(
const Key &key1,
const Key &key2) {
50 bool res = memcmp(&key1, &key2,
sizeof(Key)) == 0;
54 typename tbb::concurrent_hash_map<Key, Value, MyHashCompare> *
container;
58 container =
new tbb::concurrent_hash_map<Key, Value, MyHashCompare>
70 typename tbb::concurrent_hash_map<Key, Value, MyHashCompare>::const_accessor a;
72 if (container->find(a, key)) {
81 return container->insert( std::make_pair(key, value) );
85 typename tbb::concurrent_hash_map<Key, Value, MyHashCompare>::accessor a;
87 if (container->find(a, key)) {
88 if (a->second == value_expected) {
89 a->second = value_new;
92 value_expected = a->second;
99 bool remove(Key key) {
100 return container->erase(key);
104 return container->size();
void detach_thread()
Definition: tbb_map.h:67
bool insert(Key key, Value value)
Definition: tbb_map.h:80
static bool equal(const Key &key1, const Key &key2)
Definition: tbb_map.h:49
void attach_thread()
Definition: tbb_map.h:66
bool update(Key key, Value &value_expected, Value value_new)
Definition: tbb_map.h:84
uint64_t Value
Definition: testObject.h:59
size_t size()
Definition: tbb_map.h:103
bool find(Key key, Value &value)
Definition: tbb_map.h:69
Definition: blank_api.h:31
TestClass(size_t num_threads, size_t capacity)
Definition: tbb_map.h:57
std::string toString()
Definition: tbb_map.h:62
tbb::concurrent_hash_map< Key, Value, MyHashCompare > * container
Definition: tbb_map.h:54
static size_t hash(const Key &k)
Definition: tbb_map.h:39