File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -105,10 +105,11 @@ class Skiplist {
105
105
}
106
106
107
107
int random_level () {
108
- static const int P_INV = 2 ; // P_INV = 4 in redis implementation
108
+ static const int P_NUMERATOR = 1 ;
109
+ static const int P_DENOMINATOR = 2 ; // P = 1/4 in redis implementation
109
110
static const int MAX_LEVEL = 32 ; // enough for 2^32 elements
110
111
int level = 1 ;
111
- while (uniform_int_distribution<int >{1 , P_INV }(gen_) <= 1 &&
112
+ while (uniform_int_distribution<int >{1 , P_DENOMINATOR }(gen_) <= P_NUMERATOR &&
112
113
level < MAX_LEVEL) {
113
114
++level;
114
115
}
@@ -223,10 +224,11 @@ class Skiplist2 {
223
224
}
224
225
225
226
int random_level () {
226
- static const int P_INV = 2 ; // P_INV = 4 in redis implementation
227
+ static const int P_NUMERATOR = 1 ;
228
+ static const int P_DENOMINATOR = 2 ; // P = 1/4 in redis implementation
227
229
static const int MAX_LEVEL = 32 ; // enough for 2^32 elements
228
230
int level = 1 ;
229
- while (uniform_int_distribution<int >{1 , P_INV }(gen_) <= 1 &&
231
+ while (uniform_int_distribution<int >{1 , P_DENOMINATOR }(gen_) <= P_NUMERATOR &&
230
232
level < MAX_LEVEL) {
231
233
++level;
232
234
}
You can’t perform that action at this time.
0 commit comments