private void rehash(int newLength) { // System.out.println( "REHASH: " + array.length + " " + newLength + " " + currentSize ); AnyType[] oldArray = array; // Create a new double-sized, empty table allocateArray(nextPrime(newLength)); currentSize = 0; // Copy table over for (AnyType str : oldArray) if (str != null) insert(str); }
/** * Construct the hash table. * * @param hf the hash family * @param size the approximate initial size. */ public CuckooHashTable(HashFamily<? super AnyType> hf, int size) { allocateArray(nextPrime(size)); doClear(); hashFunctions = hf; numHashFunctions = hf.getNumberOfFunctions(); }