Making use of std::stack instead of std::queue

This commit is contained in:
2026-01-30 15:56:51 +02:00
parent af05dfcf0d
commit d21bc60024

View File

@@ -16,7 +16,7 @@
#include <cstdint> #include <cstdint>
#include <functional> #include <functional>
#include <optional> #include <optional>
#include <queue> #include <stack>
#include <tuple> #include <tuple>
#include <utility> #include <utility>
#include <variant> #include <variant>
@@ -53,9 +53,8 @@ public:
if (graveyard.empty()) { if (graveyard.empty()) {
hashList.push_back(hash); hashList.push_back(hash);
} else { } else {
std::size_t tombstone = graveyard.front(); hashList[graveyard.top()] = hash;
graveyard.pop(); graveyard.pop();
hashList[tombstone] = hash;
} }
return {hash->firstKey, hash->secondKey, hash->value}; return {hash->firstKey, hash->secondKey, hash->value};
@@ -221,7 +220,7 @@ private:
// It makes more sense to store the individual hash // It makes more sense to store the individual hash
std::vector<DualkeyHash *> hashList; std::vector<DualkeyHash *> hashList;
std::queue<std::size_t> graveyard; std::stack<std::size_t> graveyard;
}; };
} // namespace Tourmaline::Containers } // namespace Tourmaline::Containers
#endif #endif