Handle decrementing end
This commit is contained in:
@@ -1015,6 +1015,8 @@ void materializeMutations(VersionedMap::Iterator::Impl *impl, const Entry *prev,
|
||||
}
|
||||
|
||||
VersionedMap::Iterator &VersionedMap::Iterator::operator++() {
|
||||
impl->cmp = 1;
|
||||
|
||||
if (impl->mutationIndex < impl->mutationCount - 1) {
|
||||
++impl->mutationIndex;
|
||||
return *this;
|
||||
@@ -1040,19 +1042,46 @@ VersionedMap::Iterator VersionedMap::Iterator::operator++(int) {
|
||||
}
|
||||
|
||||
VersionedMap::Iterator &VersionedMap::Iterator::operator--() {
|
||||
impl->cmp = -1;
|
||||
|
||||
if (impl->mutationIndex > 0) {
|
||||
--impl->mutationIndex;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// TODO support decrementing end
|
||||
// Handle decrementing end
|
||||
if (impl->finger.searchPathSize() == 0) {
|
||||
bool ignored;
|
||||
impl->finger.push(
|
||||
impl->map->roots.getThreadSafeHandle().rootForVersion(impl->version),
|
||||
ignored);
|
||||
assert(impl->finger.backNode() != 0);
|
||||
uint32_t c;
|
||||
while ((c = impl->map->child<std::memory_order_acquire>(
|
||||
impl->finger.backNode(), true, impl->version)) != 0) {
|
||||
impl->finger.push(c, true);
|
||||
}
|
||||
|
||||
const Entry *next = nullptr;
|
||||
for (;;) {
|
||||
materializeMutations(impl, nullptr, next);
|
||||
if (impl->mutationCount > 0) {
|
||||
break;
|
||||
}
|
||||
next = impl->map->mm.base[impl->finger.backNode()].entry;
|
||||
impl->map->move<std::memory_order_acquire>(impl->finger, impl->version,
|
||||
false);
|
||||
}
|
||||
impl->mutationIndex = impl->mutationCount - 1;
|
||||
return *this;
|
||||
}
|
||||
|
||||
do {
|
||||
const auto &entry = *impl->map->mm.base[impl->finger.backNode()].entry;
|
||||
const Entry *entry = impl->map->mm.base[impl->finger.backNode()].entry;
|
||||
impl->map->move<std::memory_order_acquire>(impl->finger, impl->version,
|
||||
false);
|
||||
if (impl->finger.searchPathSize() > 0) {
|
||||
materializeMutations(impl, nullptr, &entry);
|
||||
materializeMutations(impl, nullptr, entry);
|
||||
}
|
||||
} while (impl->mutationCount == 0);
|
||||
impl->mutationIndex = impl->mutationCount - 1;
|
||||
|
Reference in New Issue
Block a user