From 262cbe637e56b29ae84e1ff9be5188c6031187e5 Mon Sep 17 00:00:00 2001 From: Iurii Tatishchev Date: Thu, 27 Jun 2024 20:15:53 -0700 Subject: [PATCH] last minute hashtable fixes --- HashTable.h | 5 +++-- main.cpp | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HashTable.h b/HashTable.h index ed66a99..e5edf7d 100644 --- a/HashTable.h +++ b/HashTable.h @@ -210,7 +210,7 @@ void HashTable::_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 &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 &hashTable, const string &filename, string v } } + cout << "Data written to file \"" << filename << "\".\n"; outputFile.close(); } diff --git a/main.cpp b/main.cpp index 201a2bf..f48740d 100644 --- a/main.cpp +++ b/main.cpp @@ -199,5 +199,4 @@ void handleFileOutput(HashTable &hashTable, UndoManager &undoManager) cin >> filename; writeToFile(hashTable, filename, to_string); undoManager.clearUndoStack(); - cout << "Data written to file \"" << filename << "\".\n"; }