Add operator== for Finger
This commit is contained in:
@@ -449,6 +449,21 @@ struct Finger {
|
|||||||
Finger(Finger &&) = delete;
|
Finger(Finger &&) = delete;
|
||||||
Finger &operator=(Finger &&) = delete;
|
Finger &operator=(Finger &&) = delete;
|
||||||
|
|
||||||
|
bool operator==(const Finger &other) const {
|
||||||
|
bool result = searchPathSize_ == other.searchPathSize_ &&
|
||||||
|
(searchPathSize_ == 0 || backNode() == other.backNode());
|
||||||
|
#ifndef NDEBUG
|
||||||
|
auto expected = searchPathSize_ == other.searchPathSize_ &&
|
||||||
|
memcmp(searchPath, other.searchPath,
|
||||||
|
searchPathSize_ * sizeof(searchPath[0])) == 0 &&
|
||||||
|
(searchPathSize_ == 0 ||
|
||||||
|
memcmp(direction + 1, other.direction + 1,
|
||||||
|
(searchPathSize_ - 1) * sizeof(direction[0])) == 0);
|
||||||
|
assert(result == expected);
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t searchPath[kPathLengthUpperBound];
|
uint32_t searchPath[kPathLengthUpperBound];
|
||||||
bool direction[kPathLengthUpperBound];
|
bool direction[kPathLengthUpperBound];
|
||||||
@@ -951,11 +966,7 @@ struct VersionedMap::Iterator::Impl {
|
|||||||
bool equals(const Impl &other) const {
|
bool equals(const Impl &other) const {
|
||||||
assert(map == other.map);
|
assert(map == other.map);
|
||||||
assert(version == other.version);
|
assert(version == other.version);
|
||||||
if (finger.searchPathSize() == 0 || other.finger.searchPathSize() == 0) {
|
return finger == other.finger && mutationIndex == other.mutationIndex;
|
||||||
return finger.searchPathSize() == other.finger.searchPathSize();
|
|
||||||
}
|
|
||||||
return finger.backNode() == other.finger.backNode() &&
|
|
||||||
mutationIndex == other.mutationIndex;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user