last minute hashtable fixes

This commit is contained in:
Iurii Tatishchev 2024-06-27 20:15:53 -07:00
parent 4882cd51fa
commit 262cbe637e
Signed by: CaZzzer
GPG Key ID: E0EBF441EA424369
2 changed files with 3 additions and 3 deletions

View File

@ -210,7 +210,7 @@ void HashTable<T>::_reHash(int h(const T &key, int size)) {
if (nHashAry[nIndex].getOccupied() != 1) {
nHashAry[nIndex].setItem(aT);
nHashAry[nIndex].setOccupied(1);
nHashAry[nIndex].setNumCollisions(i);
nHashAry[nIndex].setNumCollisions(j);
break;
}
@ -238,7 +238,7 @@ void writeToFile(const HashTable<T> &hashTable, const string &filename, string v
if (!outputFile.good()) {
cout << "Error opening the output file: \"" << filename << "\"" << endl;
exit(EXIT_FAILURE);
return;
}
outputFile.flush();
@ -252,6 +252,7 @@ void writeToFile(const HashTable<T> &hashTable, const string &filename, string v
}
}
cout << "Data written to file \"" << filename << "\".\n";
outputFile.close();
}

View File

@ -199,5 +199,4 @@ void handleFileOutput(HashTable<CPU> &hashTable, UndoManager<CPU> &undoManager)
cin >> filename;
writeToFile(hashTable, filename, to_string);
undoManager.clearUndoStack();
cout << "Data written to file \"" << filename << "\".\n";
}