Added Scan() to go through the dualkey map

This commit is contained in:
2026-01-28 14:20:55 +02:00
parent 7000aa712b
commit 4cc10ddc21

View File

@@ -124,7 +124,7 @@ public:
return amountDeleted; return amountDeleted;
} }
[[nodiscard("Discarding an expensive operation's result!")]] [[nodiscard("Discarding an expensive query!")]]
std::vector<QueryResult> query(std::optional<AKey> firstKey, std::vector<QueryResult> query(std::optional<AKey> firstKey,
std::optional<BKey> secondKey) { std::optional<BKey> secondKey) {
bool isFirstKeyGiven = firstKey.has_value(); bool isFirstKeyGiven = firstKey.has_value();
@@ -180,6 +180,18 @@ public:
return finishedQuery; return finishedQuery;
} }
void
scan(std::function<bool(const AKey &, const BKey &, Value &)> scanFunction) {
for (DualkeyHash *hash : hashList) {
if (hash == nullptr) {
continue;
}
if (scanFunction(hash->firstKey, hash->secondKey, hash->value)) {
return;
}
}
}
[[nodiscard]] [[nodiscard]]
std::size_t count() { std::size_t count() {
return hashList.size() - graveyard.size(); return hashList.size() - graveyard.size();