From ffe6dd83ca482c9d02449786b4e483b925630f19 Mon Sep 17 00:00:00 2001 From: cat Date: Mon, 2 Mar 2026 04:02:46 +0200 Subject: [PATCH] Hashmap added Count() --- headers/Containers/Hashmap.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/headers/Containers/Hashmap.hpp b/headers/Containers/Hashmap.hpp index 6a52222..dd23fd7 100644 --- a/headers/Containers/Hashmap.hpp +++ b/headers/Containers/Hashmap.hpp @@ -30,6 +30,7 @@ public: if (storage[keyHashPosition] == nullptr) { storage[keyHashPosition] = new std::vector; storage[keyHashPosition]->emplace_back(key, std::move(value), keyHash); + ++count; return storage[keyHashPosition]->back().value; } @@ -39,6 +40,7 @@ public: Has(key)); storage[keyHashPosition]->emplace_back(key, std::move(value), keyHash); + ++count; return storage[keyHashPosition]->back().value; } @@ -54,6 +56,7 @@ public: [keyHash, &key](const hashStorage &hash) { return hash.hash == keyHash && hash.key == key; }); + --count; } bool Has(const Key &key) { @@ -102,8 +105,11 @@ public: entry->clear(); delete entry; } + count = 0; } + std::size_t Count() { return count; } + private: struct hashStorage { Key key; @@ -113,6 +119,7 @@ private: using bucket = std::vector; std::vector storage; + std::size_t count = 0; }; } // namespace Tourmaline::Containers #endif