Files
hashmap-bench/src/includes/prepare.h
2020-02-18 00:00:25 -03:00

85 lines
2.5 KiB
C++

#ifndef PREPARE_H
#define PREPARE_H
#include <string>
// hashmaps and hash
#include <unordered_map>
#include "3thparty/sparsehash/sparse_hash_map"
#include "3thparty/sparsehash/dense_hash_map"
#include "./3thparty/abseil-cpp/absl/container/node_hash_map.h"
#include "./3thparty/abseil-cpp/absl/container/flat_hash_map.h"
#include "./3thparty/abseil-cpp/absl/hash/hash.h"
#include "./3thparty/tsl/sparse_map.h"
#include "./3thparty/tsl/array_map.h"
#include "./3thparty/tsl/ordered_map.h"
#include "./3thparty/tsl/robin_map.h"
#include "./3thparty/tsl/hopscotch_map.h"
#include <boost/unordered_map.hpp>
#include "./3thparty/skarupke/bytell_hash_map.hpp"
#include "./3thparty/skarupke/flat_hash_map.hpp"
#include "./3thparty/skarupke/unordered_map.hpp"
#include "./3thparty/parallel_hashmap/phmap.h"
#include "./3thparty/emilib/hash_map.hpp"
#include "3thparty/robinhood/robin_hood.h"
using std::string;
using absl::Hash;
// this is the prepare function, again using template
// this is for all maps which only need this. Below are the ones that
// need something different
template<class T>
void prepare(T& map, int size) {
map.reserve(size);
}
// needs a tombstone marker(a key that's exclusively used to signify something
// is deleted) and it doesn't have a reserve(size) member
void prepare(google::sparse_hash_map<int, int>& map, int size) {
map.set_deleted_key(-1);
}
void prepare(google::sparse_hash_map<string, string>& map, int size) {
map.set_deleted_key("a");
}
// needs a tombstone marker(a key that's exclusively used to signify something
// is deleted) and an empty key marker
// and it doesn't have a reserve(size) member
void prepare(google::dense_hash_map<int, int>& map, int size) {
map.set_empty_key(0);
map.set_deleted_key(-1);
}
void prepare(google::dense_hash_map<string, string>& map, int size) {
map.set_deleted_key("a");
map.set_empty_key("");
}
// with abseil hash
// this is a repeat of the 4 written above, but with types that accept abseil::Hash as hashing function
void prepare(google::sparse_hash_map<int, int, Hash<int>>& map, int size) {
map.set_deleted_key(-1);
}
void prepare(google::sparse_hash_map<string, string, Hash<string>>& map, int size) {
map.set_deleted_key("a");
}
void prepare(google::dense_hash_map<int, int, Hash<int>>& map, int size) {
map.set_empty_key(0);
map.set_deleted_key(-1);
}
void prepare(google::dense_hash_map<string, string, Hash<string>>& map, int size) {
map.set_deleted_key("a");
map.set_empty_key("");
}
#endif /* TESTS_H */