about summary refs log tree commit diff stats
path: root/src/server/main.cpp
diff options
context:
space:
mode:
authorckrinitsin <101062646+ckrinitsin@users.noreply.github.com>2025-03-20 12:15:53 +0100
committerGitHub <noreply@github.com>2025-03-20 12:15:53 +0100
commitae8de5f25623ed6f39f8f6c9c0f837c8f286b8c0 (patch)
treeffae5c5b9498ce82fe53244aebb7c7dafc46d4ab /src/server/main.cpp
parent481c97567aa1cb54edd169841d1266a7a59a0227 (diff)
parenta509d8e7c953aa80eed3b7288bd3af9bca68dd48 (diff)
downloadBT-Programming-Assignment-ae8de5f25623ed6f39f8f6c9c0f837c8f286b8c0.tar.gz
BT-Programming-Assignment-ae8de5f25623ed6f39f8f6c9c0f837c8f286b8c0.zip
Merge pull request #1 from ckrinitsin/hashtable
Hashtable
Diffstat (limited to 'src/server/main.cpp')
-rw-r--r--src/server/main.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/server/main.cpp b/src/server/main.cpp
index e04a1cf..b2f8bed 100644
--- a/src/server/main.cpp
+++ b/src/server/main.cpp
@@ -1,5 +1,4 @@
 #include <cstdint>
-#include <cstdio>
 #include <stdexcept>
 #include <string>
 
@@ -8,7 +7,7 @@
 int main(int argc, char* argv[])
 {
     if (argc != 2) {
-        std::printf("One argument required");
+        std::cout << "One argument required" << '\n';
         return 1;
     }
 
@@ -16,10 +15,32 @@ int main(int argc, char* argv[])
     try {
         size = std::stoi(std::string(argv[1]));
     } catch (const std::invalid_argument& e) {
-        std::printf("Invalid argument");
+        std::cout << "Invalid argument" << '\n';
         return 1;
     }
+  
+    HashTable<int, std::string> hash_table { size };
 
+    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();
 
     return 0;
 }