Created
August 29, 2011 07:41
-
-
Save delamonpansie/1177952 to your computer and use it in GitHub Desktop.
put
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static uint32_t | |
_mh(put_slot)(struct _mh(t) *h, mh_key_t key) | |
{ | |
uint32_t inc, k, i, p = h->n_buckets; | |
k = mh_hash(key); | |
i = k % h->n_buckets; | |
inc = 1 + k % (h->n_buckets - 1); | |
for (;;) { | |
if (mh_exist(h, i)) { | |
if (mh_eq(h->p[i].key, key)) | |
return i; | |
if (p == h->n_buckets) | |
mh_setdirty(h, i); | |
} else { | |
if (p == h->n_buckets) | |
p = i; | |
if (!mh_dirty(h, i)) | |
return p; | |
} | |
i += inc; | |
if (i >= h->n_buckets) | |
i -= h->n_buckets; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment