Alex_tz307

Custom Hash Map

Sep 12th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. struct custom_hash {
  2.     static int splitmix(int x) {
  3.         x += 0x9e3779b97f4a7c15;
  4.         x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
  5.         x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
  6.         return x ^ (x >> 31);
  7.     }
  8.     size_t operator()(int x) const {
  9.         static const int FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
  10.         return splitmix(x + FIXED_RANDOM);
  11.     }
  12. };
  13.  
  14. unordered_map < int , int , custom_hash > Hash;
Advertisement
Add Comment
Please, Sign In to add comment