diff options
| author | mzuenni <michi.zuendorf@gmail.com> | 2022-06-27 17:19:28 +0200 |
|---|---|---|
| committer | mzuenni <michi.zuendorf@gmail.com> | 2022-06-27 17:19:28 +0200 |
| commit | 5ab8a5088b729a9953b8dff1b2a985dc8fb2098b (patch) | |
| tree | ed40d6936c0e9eee40ba62751cbf99ecddbaddc2 /datastructures/stlHashMap.cpp | |
| parent | adabbad9c51cf7cd3874bfde8eac1fbcf84fec10 (diff) | |
updated tcr
Diffstat (limited to 'datastructures/stlHashMap.cpp')
| -rw-r--r-- | datastructures/stlHashMap.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/datastructures/stlHashMap.cpp b/datastructures/stlHashMap.cpp new file mode 100644 index 0000000..b107dde --- /dev/null +++ b/datastructures/stlHashMap.cpp @@ -0,0 +1,17 @@ +#include <ext/pb_ds/assoc_container.hpp> +using namespace __gnu_pbds; + +template<typename T> +struct betterHash { + size_t operator()(T o) const { + size_t h = hash<T>()(o) ^ 42394245; //random value + h = ((h >> 16) ^ h) * 0x45d9f3b; + h = ((h >> 16) ^ h) * 0x45d9f3b; + h = ((h >> 16) ^ h); + return h; +}}; + +template<typename K, typename V, typename H = betterHash<K>> +using hashMap = gp_hash_table<K, V, H>; +template<typename K, typename H = betterHash<K>> +using hashSet = gp_hash_table<K, null_type, H>; |
