Compare commits
2 Commits
3fc4f3ec84
...
16c1a2c620
| Author | SHA1 | Date | |
|---|---|---|---|
| 16c1a2c620 | |||
| baa8cc351d |
@@ -44,10 +44,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Entry insert(AKey firstKey, BKey secondKey, Value value) {
|
Entry insert(AKey firstKey, BKey secondKey, Value value) {
|
||||||
std::size_t firstKeyHash = std::hash<AKey>{}(firstKey);
|
DualkeyHash *hash = new DualkeyHash(std::move(firstKey),
|
||||||
std::size_t secondKeyHash = std::hash<BKey>{}(secondKey);
|
|
||||||
DualkeyHash *hash =
|
|
||||||
new DualkeyHash(firstKeyHash, std::move(firstKey), secondKeyHash,
|
|
||||||
std::move(secondKey), std::move(value));
|
std::move(secondKey), std::move(value));
|
||||||
|
|
||||||
if (graveyard.empty()) {
|
if (graveyard.empty()) {
|
||||||
@@ -79,7 +76,6 @@ public:
|
|||||||
std::size_t index = 0, amountDeleted = 0;
|
std::size_t index = 0, amountDeleted = 0;
|
||||||
uint8_t stateOfIndexing = isFirstKeyGiven + (isSecondKeyGiven << 1);
|
uint8_t stateOfIndexing = isFirstKeyGiven + (isSecondKeyGiven << 1);
|
||||||
for (DualkeyHash *hash : hashList) {
|
for (DualkeyHash *hash : hashList) {
|
||||||
|
|
||||||
// Tombstone
|
// Tombstone
|
||||||
if (hash == nullptr) [[unlikely]] {
|
if (hash == nullptr) [[unlikely]] {
|
||||||
continue;
|
continue;
|
||||||
@@ -179,8 +175,22 @@ public:
|
|||||||
return finishedQuery;
|
return finishedQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void scan(std::function<bool(const std::size_t firstKeyHash,
|
||||||
scan(std::function<bool(const AKey &, const BKey &, Value &)> scanFunction) {
|
const std::size_t secondKeyHash, Value &value)>
|
||||||
|
scanFunction) {
|
||||||
|
for (DualkeyHash *hash : hashList) {
|
||||||
|
if (hash == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (scanFunction(hash->firstKeyHash, hash->secondKeyHash, hash->value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void scan(std::function<bool(const AKey &firstKey, const BKey &secondKey,
|
||||||
|
Value &value)>
|
||||||
|
scanFunction) {
|
||||||
for (DualkeyHash *hash : hashList) {
|
for (DualkeyHash *hash : hashList) {
|
||||||
if (hash == nullptr) {
|
if (hash == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
@@ -205,16 +215,16 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
struct DualkeyHash {
|
struct DualkeyHash {
|
||||||
DualkeyHash(std::size_t firstKeyHash, AKey &&firstKey,
|
DualkeyHash(AKey &&firstKey, BKey &&secondKey, Value &&value)
|
||||||
std::size_t secondKeyHash, BKey &&secondKey, Value &&value)
|
: firstKey(std::move(firstKey)), secondKey(std::move(secondKey)),
|
||||||
: firstKeyHash(firstKeyHash), secondKeyHash(secondKeyHash),
|
firstKeyHash(std::hash<AKey>{}(this->firstKey)),
|
||||||
firstKey(std::move(firstKey)), secondKey(std::move(secondKey)),
|
secondKeyHash(std::hash<BKey>{}(this->secondKey)),
|
||||||
value(std::move(value)) {}
|
value(std::move(value)) {}
|
||||||
|
|
||||||
const std::size_t firstKeyHash;
|
|
||||||
const std::size_t secondKeyHash;
|
|
||||||
const AKey firstKey;
|
const AKey firstKey;
|
||||||
const BKey secondKey;
|
const BKey secondKey;
|
||||||
|
const std::size_t firstKeyHash;
|
||||||
|
const std::size_t secondKeyHash;
|
||||||
mutable Value value;
|
mutable Value value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user