fork(1) download
  1.  
  2. #include <bits/stdc++.h>
  3. #include <ext/pb_ds/assoc_container.hpp>
  4. using namespace __gnu_pbds;
  5. using namespace std;
  6.  
  7. typedef gp_hash_table<
  8. int, null_type, hash<int>, equal_to<int>, direct_mask_range_hashing<int>, linear_probe_fn<>,
  9. hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>>
  10. gp;
  11.  
  12. typedef cc_hash_table<
  13. int, null_type, hash<int>, equal_to<int>, direct_mask_range_hashing<int>,
  14. hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>>
  15. cc;
  16.  
  17. const int N = 3e6;
  18. int getTicks() {
  19. static auto startTime = std::chrono::high_resolution_clock::now();
  20. auto t = std::chrono::high_resolution_clock::now();
  21. return std::chrono::duration_cast<std::chrono::milliseconds>(t - startTime).count();
  22. }
  23. int main() {
  24. gp table;
  25. table.resize(N);
  26. table.set_loads({.25, .5});
  27. int s = getTicks();
  28. for (int i = 0; i < N; i++)
  29. table.insert(i);
  30. for (int i = 0; i < N; i++)
  31. table.erase(i);
  32.  
  33. cout << getTicks() - s << endl;
  34. s = getTicks();
  35. gp_hash_table<int, null_type> table2;
  36.  
  37. for (int i = 0; i < N; i++)
  38. table2.insert(i);
  39. for (int i = 0; i < N; i++)
  40. table2.erase(i);
  41. cout << getTicks() - s << endl;
  42. return 0;
  43. }
  44.  
Success #stdin #stdout 0.25s 101312KB
stdin
Standard input is empty
stdout
138
92