Obj* Hash_Delete_IMP(Hash *self, Obj *key) { HashEntry *entry = SI_fetch_entry(self, key, Obj_Hash_Sum(key)); if (entry) { Obj *value = entry->value; DECREF(entry->key); entry->key = (Obj*)TOMBSTONE; entry->value = NULL; entry->hash_sum = 0; self->size--; self->threshold--; // limit number of tombstones return value; } else { return NULL; } }
Obj* Hash_Find_Key_IMP(Hash *self, Obj *key, int32_t hash_sum) { HashEntry *entry = SI_fetch_entry(self, key, hash_sum); return entry ? entry->key : NULL; }
Obj* Hash_Fetch_IMP(Hash *self, Obj *key) { HashEntry *entry = SI_fetch_entry(self, key, Obj_Hash_Sum(key)); return entry ? entry->value : NULL; }
Obj* Hash_find_key(Hash *self, const Obj *key, int32_t hash_sum) { HashEntry *entry = SI_fetch_entry(self, key, hash_sum); return entry ? entry->key : NULL; }