+ unsigned int index = hash_function(key);
+ do {
+ index &= capacitymask;
+ search = &table[index];
+ if (!search->key) {
+ if (!search->val)
+ break;
+ } else {
+ // The case where an item is found
+ if (equals(search->key, key)) {
+ unsigned int j = index;
+ _Val v = search->val;
+ size--;
+
+ // Idea: keep bins contiguous
+ while (true) {
+ search->val = 0;
+ search->key = 0;
+
+ while (true) {
+ j = (j + 1) & capacitymask;
+ replace = &table[j];
+
+ if (!replace->key && !replace->val) {
+ return v;
+ }
+
+ unsigned int hash = hash_function(replace->key) & capacitymask;
+ if (index <= j && index < hash && hash <= j)
+ continue;
+ else if (index > j && (index < hash || hash <= j) )
+ continue;
+ else
+ break;
+ }
+
+ table[index] = table[j];
+ index = j;
+ search = &table[index];
+ }
+ }