The removal of an entry from a hash table is somewhat easy. The code is captured in listing 4.
Listing 4: | hashremoval |
Well, this code is not entirely correct, but it does capture some of the important concepts. First, we need to check if the key does correspond to any item in the hash table. We check flags and see if the bit corresponding to HASNENTRY_INUSE is set. If so, we proceed to delete the entry. The deletion simply decrements the size and reset the “in use” bit.