Last active
January 15, 2022 00:53
-
-
Save Chillee/3bd6ee4429abb4a2e7c19959fb1490ae to your computer and use it in GitHub Desktop.
Policy based data structures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ext/pb_ds/assoc_container.hpp> | |
using namespace __gnu_pbds; | |
struct chash { | |
const int RANDOM = (long long)(make_unique<char>().get()) ^ chrono::high_resolution_clock::now().time_since_epoch().count(); | |
static unsigned long long hash_f(unsigned long long x) { | |
x += 0x9e3779b97f4a7c15; | |
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; | |
x = (x ^ (x >> 27)) * 0x94d049bb133111eb; | |
return x ^ (x >> 31); | |
} | |
static unsigned hash_combine(unsigned a, unsigned b) { return a * 31 + b; } | |
int operator()(int x) const { return hash_f(x)^RANDOM; } | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ext/pb_ds/assoc_container.hpp> | |
using namespace __gnu_pbds; | |
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // order_of_key, find_by_order |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment