Skip to content

Commit 928581a

Browse files
fixed a bug in khashl; resolves #135
1 parent 6f73c80 commit 928581a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

cpp/khashl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class KHashSet {
144144
j = (j + khint_t(1)) & mask;
145145
if (j == i || !__kh_used(used, j)) break; /* j==i only when the table is completely full */
146146
k = __kh_h2b(Hash()(keys[j]), bits);
147-
if (k <= i || k > j)
147+
if ((j > i && (k <= i || k > j)) || (j < i && (k <= i && k > j)))
148148
keys[i] = keys[j], i = j;
149149
}
150150
__kh_set_unused(used, i);

khashl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static kh_inline khint_t __kh_h2b(khint_t hash, khint_t bits) { return hash * 26
230230
j = (j + 1U) & mask; \
231231
if (j == i || !__kh_used(h->used, j)) break; /* j==i only when the table is completely full */ \
232232
k = __kh_h2b(__hash_fn(h->keys[j]), h->bits); \
233-
if (k <= i || k > j) \
233+
if ((j > i && (k <= i || k > j)) || (j < i && (k <= i && k > j))) \
234234
h->keys[i] = h->keys[j], i = j; \
235235
} \
236236
__kh_set_unused(h->used, i); \

0 commit comments

Comments
 (0)