fixed a bug in khashl; resolves #135

This commit is contained in:
Attractive Chaos 2020-01-13 20:05:38 -05:00
parent 6f73c80c64
commit 928581a784
2 changed files with 2 additions and 2 deletions

View File

@ -144,7 +144,7 @@ public:
j = (j + khint_t(1)) & mask;
if (j == i || !__kh_used(used, j)) break; /* j==i only when the table is completely full */
k = __kh_h2b(Hash()(keys[j]), bits);
if (k <= i || k > j)
if ((j > i && (k <= i || k > j)) || (j < i && (k <= i && k > j)))
keys[i] = keys[j], i = j;
}
__kh_set_unused(used, i);

View File

@ -230,7 +230,7 @@ static kh_inline khint_t __kh_h2b(khint_t hash, khint_t bits) { return hash * 26
j = (j + 1U) & mask; \
if (j == i || !__kh_used(h->used, j)) break; /* j==i only when the table is completely full */ \
k = __kh_h2b(__hash_fn(h->keys[j]), h->bits); \
if (k <= i || k > j) \
if ((j > i && (k <= i || k > j)) || (j < i && (k <= i && k > j))) \
h->keys[i] = h->keys[j], i = j; \
} \
__kh_set_unused(h->used, i); \