Compare commits
1 Commits
main
...
7159ddd935
| Author | SHA1 | Date | |
|---|---|---|---|
| 7159ddd935 |
@@ -48,11 +48,16 @@ public:
|
|||||||
new DualkeyHash(firstKeyHash, std::move(firstKey), secondKeyHash,
|
new DualkeyHash(firstKeyHash, std::move(firstKey), secondKeyHash,
|
||||||
std::move(secondKey), std::move(value));
|
std::move(secondKey), std::move(value));
|
||||||
|
|
||||||
if (tombstones.empty()) {
|
if (graveyard.empty()) {
|
||||||
hashList.push_back(hash);
|
hashList.push_back(hash);
|
||||||
|
Systems::Logging::Log("Empty graveyard", "DKM",
|
||||||
|
Systems::Logging::LogLevel::Info);
|
||||||
} else {
|
} else {
|
||||||
std::size_t tombstone = tombstones.back();
|
std::size_t tombstone = graveyard.back();
|
||||||
tombstones.pop();
|
graveyard.pop();
|
||||||
|
|
||||||
|
Systems::Logging::Log("Using a tombstone", "DKM",
|
||||||
|
Systems::Logging::LogLevel::Info);
|
||||||
hashList[tombstone] = hash;
|
hashList[tombstone] = hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,20 +93,20 @@ public:
|
|||||||
firstKey.value() == hash->firstKey) {
|
firstKey.value() == hash->firstKey) {
|
||||||
delete hash;
|
delete hash;
|
||||||
hashList[index] = nullptr;
|
hashList[index] = nullptr;
|
||||||
tombstones.push(index);
|
graveyard.push(index);
|
||||||
++amountDeleted;
|
++amountDeleted;
|
||||||
}
|
}
|
||||||
continue;
|
break;
|
||||||
|
|
||||||
case 2: // Only second key is given
|
case 2: // Only second key is given
|
||||||
if (secondKeyHash == hash->secondKeyHash &&
|
if (secondKeyHash == hash->secondKeyHash &&
|
||||||
secondKey.value() == hash->secondKey) {
|
secondKey.value() == hash->secondKey) {
|
||||||
delete hash;
|
delete hash;
|
||||||
hashList[index] = nullptr;
|
hashList[index] = nullptr;
|
||||||
tombstones.push(index);
|
graveyard.push(index);
|
||||||
++amountDeleted;
|
++amountDeleted;
|
||||||
}
|
}
|
||||||
continue;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
if (firstKeyHash == hash->firstKeyHash &&
|
if (firstKeyHash == hash->firstKeyHash &&
|
||||||
@@ -110,12 +115,11 @@ public:
|
|||||||
secondKey.value() == hash->secondKey) {
|
secondKey.value() == hash->secondKey) {
|
||||||
delete hash;
|
delete hash;
|
||||||
hashList[index] = nullptr;
|
hashList[index] = nullptr;
|
||||||
tombstones.push(index);
|
graveyard.push(index);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
return amountDeleted;
|
return amountDeleted;
|
||||||
@@ -203,7 +207,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> tombstones;
|
std::queue<std::size_t> graveyard;
|
||||||
};
|
};
|
||||||
} // namespace Tourmaline::Containers
|
} // namespace Tourmaline::Containers
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user