private int expungeStaleEntry ( int staleSlot ) { Entry [ ] tab = table ; int len = tab . length ; // expunge entry at staleSlot tab [ staleSlot ] . value = null ; tab [ staleSlot ] = null ; size -- ; // Rehash until we encounter null Entry e ; int i ; for ( i = nextIndex ( staleSlot , len ) ; ( e = tab [ i ] ) != null ; i = nextIndex ( i , len ) ) { int h = e . key . hashCode & ( len - 1 ) ; if ( h != i ) { tab [ i ] = null ; // Unlike Knuth 6.4 Algorithm R, we must scan until // null because multiple entries could have been stale. while ( tab [ h ] != null ) h = nextIndex ( h , len ) ; tab [ h ] = e ; } } return i ; }
Expunge a stale entry by rehashing any possibly colliding entries lying between staleSlot and the next null slot . This also expunges any other stale entries encountered before the trailing null . See Knuth Section 6 . 4