Shifting deletion algorithm for linear-probing hash table
There are two main approaches to cover the "wraparound" case:


"Triple condition", e. g. see java.util.IdentityHashMap source, or with more clarifying comments here
Second approach is based on counting the distance to the empty slot and comparing it with the distance between the slot where the "candidate for shift" is observed and where it should have been inserted if the hash table is empty, which could be obtained (covering the wraparound case) by substracting the index of the slot where the key should have been isnerted from the index of the current slot in the table, modulo table size (binary &amp; (tableSize - 1) if the table size is a power of two). Example imlementation of this approach could be found here.