void HashTable<Type> :: updateTableCapacity() { int updatedCapacity = getNextPrime(); CTECList<HashNode<Type>> * updateTable = new CTECList<HashNode<Type>> [updatedCapacity]; int oldTableCapacity = tableCapacity; tableCapacity = updatedCapacity; for(int index = 0; index < oldTableCapacity; index++) { if (tableStorage[index] != nullptr) { CTECList<HashNode<Type>> temp = tableStorage[index]; for(int innerIndex = 0; innerIndex < temp.getSize(); innerIndex++) { int updatedTablePosition = findPosition(temp.get(index)); if(updateTable[updatedTablePosition] == nullptr) { CTECList<HashTable<Type>> updatedList; updatedList.addEnd(temp.get(index)); } else { updateTable[updatedTablePosition].addEnd(temp.get(index)); } } } } }
void CTECHashTable<Type>::addToTable(HashNode<Type> currentNode) { if(this->tableSize / this->tableCapacity >= this->efficiencyPercentage) { updateTableCapacity(); } int positionToInsert = findPosition(currentNode); if(tableStorage[positionToInsert] == nullptr) { CTECList<HashNode<Type> > hashList; tableStorage[positionToInsert] = hashList; hashList.addEnd(currentNode); } else { tableStorage[positionToInsert].addEnd(currentNode); } }