From 090af1b8097fecf6b09f3048811a44e11ece3242 Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Thu, 3 Apr 2025 06:07:34 -0500 Subject: Test hash map extract pair, fix bugs. --- include/fud_hash_map.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'include/fud_hash_map.hpp') diff --git a/include/fud_hash_map.hpp b/include/fud_hash_map.hpp index 9220876..ba9e0c2 100644 --- a/include/fud_hash_map.hpp +++ b/include/fud_hash_map.hpp @@ -200,7 +200,7 @@ class HashMap { if (hashIndexOption.isNone()) { return insert(key, value); } - auto hashIndex{hashIndexOption.take()}; + auto hashIndex{hashIndexOption.value()}; m_data[hashIndex].value() = value; return FudStatus::Success; } @@ -211,7 +211,7 @@ class HashMap { if (hashIndexOption.isNone()) { return insert(key, std::move(value)); } - auto hashIndex{hashIndexOption.take()}; + auto hashIndex{hashIndexOption.value()}; m_data[hashIndex].value() = std::move(value); return FudStatus::Success; } @@ -222,7 +222,7 @@ class HashMap { if (hashIndexOption.isNone()) { return insert(std::move(key), value); } - auto hashIndex{hashIndexOption.take()}; + auto hashIndex{hashIndexOption.value()}; m_data[hashIndex].value() = value; return FudStatus::Success; } @@ -233,7 +233,7 @@ class HashMap { if (hashIndexOption.isNone()) { return insert(std::move(key), std::move(value)); } - auto hashIndex{hashIndexOption.take()}; + auto hashIndex{hashIndexOption.value()}; m_data[hashIndex].value() = std::move(value); return FudStatus::Success; } @@ -290,7 +290,7 @@ class HashMap { return value; } - KeyValuePair extractPair(const Key& key) + Option extractPair(const Key& key) { auto hashIndexOption = lookup(key); if (hashIndexOption.isNone()) { @@ -298,13 +298,13 @@ class HashMap { } auto hashIndex{hashIndexOption.value()}; - KeyValuePair kvPair{key, m_data[hashIndex].takeValue()}; + KeyValuePair kvPair{std::move(m_data[hashIndex].takeKey()), std::move(m_data[hashIndex].takeValue())}; m_data[hashIndex].tombstone(); return kvPair; } - KeyValuePair extractPair(Key&& key) + Option extractPair(Key&& key) { auto hashIndexOption = lookup(key); if (hashIndexOption.isNone()) { @@ -312,7 +312,7 @@ class HashMap { } auto hashIndex{hashIndexOption.value()}; - KeyValuePair kvPair{std::move(key), m_data[hashIndex].takeValue()}; + KeyValuePair kvPair{std::move(key), std::move(m_data[hashIndex].takeValue())}; m_data[hashIndex].tombstone(); return kvPair; -- cgit v1.2.3