1: // @author Frank M. Carrano, Timothy M. Henry 2: // @version 5.0 4: // Precondition: checkIntegrity has been called. 5: private void enlargeHashTable() 6: { 7: Entry<K, V>[] oldTable = hashTable; 8: int oldSize = hashTable.length; 9: int newSize = getNextPrime(oldSize + oldSize); 10: checkSize(newSize); 12: // The cast is safe because the new array contains null entries 13: @SuppressWarnings("unchecked") 14: Entry<K, V>[] temp = (Entry<K, V>[])new Entry[newSize]; 15: hashTable = temp; 16: numberOfEntries = 0; // Reset number of dictionary entries, since 17: // it will be incremented by add during rehash 18: // Rehash dictionary entries from old array to the new and bigger array; 19: // skip elements that contain null or AVAILABLE 20: for (int index = 0; index < oldSize; index++) 21: { 22: if ( (oldTable[index] != null) && oldTable[index] != AVAILABLE ) 23: add(oldTable[index].getKey(), oldTable[index].getValue()); 24: } // end for 25: } // end enlargeHashTable