From afbafc29ab11c17c2b90dd5e645f1943490c276a Mon Sep 17 00:00:00 2001 From: Christian Krinitsin Date: Thu, 20 Mar 2025 12:04:49 +0100 Subject: server: add a sample main function, which tests the hashtable --- src/server/main.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/server/main.cpp (limited to 'src') 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 + +#include "hashtable.h" + +int main(int argc, char* argv[]) +{ + HashTable 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(); + +} -- cgit 1.4.1