Apex › Storage & databases

Robin Hood hashing

An open-addressing hash table that flattens the worst case with one rule: while probing to insert, if you meet an element closer to its home than you are to yours, evict it and take the slot, carrying it onward — robbing from the "rich" (low probe distance) to help the "poor." Probe distances equalize, so the max lookup cost stays tiny. Add keys and compare the probe-distance spread against plain linear probing.

More in Storage & databases