File tree Expand file tree Collapse file tree
src/alfred/data_structure Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55#include < utility>
66#include < vector>
77
8+ std::vector<bool > s;
9+
810template <class K , class V >
911struct HashMap { // HashMap for integer keys.
1012 using u32 = unsigned int ;
@@ -23,7 +25,7 @@ struct HashMap { // HashMap for integer keys.
2325 fi.assign (lim, 0 ), tot = 0 ;
2426 mask = lim - 1 , e.resize (sz);
2527 }
26- inline void inc (K x, V delta) {
28+ inline void inc (K x, const V & delta) {
2729 u32 u = hash (x) & mask;
2830 for (u32 i = fi[u]; i; i = e[i].ne ) {
2931 if (e[i].key == x) {
Original file line number Diff line number Diff line change 44template <class T >
55struct Splitmix {
66 inline T operator ()(T x) {
7- if constexpr (sizeof (T) == 8 ) {
7+ if (sizeof (T) == 8 ) {
88 T z = (x += 0x9e3779b97f4a7c15 );
99 z = (z ^ (z >> 30 )) * 0xbf58476d1ce4e5b9 ;
1010 z = (z ^ (z >> 27 )) * 0x94d049bb133111eb ;
@@ -18,4 +18,29 @@ struct Splitmix {
1818 }
1919};
2020
21+ // use specialized version for 64bit and 32bit for older c++ standards
22+ // as if constexpr is not supported
23+
24+ template <>
25+ struct Splitmix <unsigned long long > {
26+ unsigned long long z;
27+ inline unsigned long long operator ()(unsigned long long x) {
28+ z = (x += 0x9e3779b97f4a7c15 );
29+ z = (z ^ (z >> 30 )) * 0xbf58476d1ce4e5b9 ;
30+ z = (z ^ (z >> 27 )) * 0x94d049bb133111eb ;
31+ return z ^ (z >> 31 );
32+ }
33+ };
34+
35+ template <>
36+ struct Splitmix <unsigned int > {
37+ unsigned int z;
38+ inline unsigned int operator ()(unsigned int x) {
39+ z = (x += 0x9e3779b9 );
40+ z = (z ^ (z >> 16 )) * 0x85ebca6b ;
41+ z = (z ^ (z >> 13 )) * 0xc2b2ae35 ;
42+ return z ^ (z >> 16 );
43+ }
44+ };
45+
2146#endif
You can’t perform that action at this time.
0 commit comments