private void fileElement ( Entry < T > currentElement , boolean rehash ) { int maxFailures = Math . max ( ( int ) Math . log ( this . numElements ) , this . numTables * 2 ) ; int currentTable = 0 ; for ( int i = 0 ; i < maxFailures ; i ++ ) { int hash = this . hashfunctions . get ( currentTable ) . hash ( currentElement . getKey ( ) ) ; currentElement = this . tables . get ( currentTable ) . set ( hash , currentElement ) ; if ( currentElement == null ) { break ; } currentTable = ( currentTable + 1 ) % this . numTables ; } if ( currentElement != null ) { this . stash . add ( currentElement ) ; this . stashSize ++ ; } while ( rehash && this . stashSize > this . maxStashSize ) { reset ( ) ; if ( this . stashSize > this . maxStashSize ) { increaseAndReset ( ) ; } } }
Adds an element to one of the tables for Cuckoo Hashing .