diff options
| author | Christian Krinitsin <mail@krinitsin.com> | 2025-03-20 12:04:49 +0100 |
|---|---|---|
| committer | Christian Krinitsin <mail@krinitsin.com> | 2025-03-20 12:04:49 +0100 |
| commit | afbafc29ab11c17c2b90dd5e645f1943490c276a (patch) | |
| tree | 1103dbf22d27126b269e7f62a804e68501c760a1 | |
| parent | e8abcfc7425167e96bf00a8b79de9a30ee2e2800 (diff) | |
| download | BT-Programming-Assignment-afbafc29ab11c17c2b90dd5e645f1943490c276a.tar.gz BT-Programming-Assignment-afbafc29ab11c17c2b90dd5e645f1943490c276a.zip | |
server: add a sample main function, which tests the hashtable
| -rw-r--r-- | server/src/main.cpp | 11 | ||||
| -rw-r--r-- | src/server/main.cpp | 30 |
2 files changed, 30 insertions, 11 deletions
diff --git a/server/src/main.cpp b/server/src/main.cpp deleted file mode 100644 index 26bee21..0000000 --- a/server/src/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include <cstdio> - -int main(int argc, char* argv[]) -{ - if (argc != 2) { - std::printf("The size of the hash table is needed"); - return 1; - } - - return 0; -} diff --git a/src/server/main.cpp b/src/server/main.cpp new file mode 100644 index 0000000..de99edb --- /dev/null +++ b/src/server/main.cpp @@ -0,0 +1,30 @@ +#include <string> + +#include "hashtable.h" + +int main(int argc, char* argv[]) +{ + HashTable<int, std::string> hash_table { 5 }; + + std::cout << "Add various kv-pairs" << '\n'; + hash_table.insert(1, "1"); + hash_table.insert(2, "2"); + hash_table.insert(3, "3"); + hash_table.insert(4, "4"); + hash_table.insert(5, "5"); + hash_table.insert(6, "6"); + hash_table.insert(7, "7"); + + hash_table.print(); + + std::cout << '\n'; + + std::cout << "Value for key 8: " << hash_table.get(8).value_or("Key not found!") << '\n'; + std::cout << "Value for key 4: " << hash_table.get(4).value_or("Key not found!") << '\n'; + + std::cout << '\n'; + std::cout << "Remove pair with key 5" << '\n'; + hash_table.remove(5); + hash_table.print(); + +} |