Bugfix: Hash position was calculated before rehash

This commit is contained in:
2026-03-02 08:59:42 +02:00
parent 7fd71ab0ac
commit 5112f2a3a3

View File

@@ -23,11 +23,11 @@ public:
~Hashmap() { Clear(); } ~Hashmap() { Clear(); }
Value &Insert(Key key, Value value) { Value &Insert(Key key, Value value) {
std::size_t keyHash = std::hash<Key>{}(key),
keyHashPosition = keyHash % storage.size();
if (currentLoadFactor >= loadFactor && currentlyRehashing == false) { if (currentLoadFactor >= loadFactor && currentlyRehashing == false) {
rehash(); rehash();
} }
std::size_t keyHash = std::hash<Key>{}(key),
keyHashPosition = keyHash % storage.size();
// Empty bucket // Empty bucket
if (storage[keyHashPosition] == nullptr) { if (storage[keyHashPosition] == nullptr) {